.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

problem with changing cssclass name using javascript

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :ASP.Net
function DoFocus(fld) { fld.className = 'textboxFocus'; } function ChangeToFocus() { document.getElementById('<%=tbComment.ClientID%>').className="textboxFocus"; } button1.Attributes.Add("OnClick", "ChangeToFocus();")//Not working tbComment.Attributes.Add("OnFocus", "DoFocus(this);")//Working I have two methods to change a control's css class (etc. textbox), however, javascript method 'ChangeToFocus' is not working but I do need that function or something could do the samething (I can't use DoFocus(fld) function as it need to pass that control's reference)     Many thanks for your help! Ray

View Complete Post

More Related Resource Links

Problem with JavaScript which is used when changing the value in textboxes.



This is Naveen, i am trying to upgrade a internal website from .Net 1.1 to .Net 2.0 in VB.

but the code is giving an exception in explorer the same code doesn't give exception in explorer,in the same time it doesnot work roperly..

when i try change the values in text boxes an exception is occured as

"Microsoft JScript runtime error: 'document.Form1.txtRentalCost' is null or not an object" with break continue and ignore options.

here is my JavaScript:

<script language="javascript" type="text/javascript">
    function Recalculate()
        document.Form1.txtRentalCost.value = parseFloat(document.Form1.txtRentalPerDay.value) * parseInt(document.Form1.txtNumOfDays.value) * parseInt(document.Form1.txtRate.value) / 100;




<input id="txtRentalCost" style="z-index: 114; left: 344px; width: 139px; position: absolute;
            top: 208px; height: 22px" type="text" size="17" name="txtRentalCost" runat="server" />


<input language="javascript" id="txtR

Problem with changing language using culture info


I'm using the following msdn article to use different languages in my web application:


I'm following the instructions step by step in VS 2010, and it creates the resource files exactly how it's supposed to. 

However, when I run the program it just doesn't apply it. I don't see the different values from the resource file. 

If I leave my resource file name as sample.aspx.resx, it works. But when I change it to sample.aspx.en-us.resx, it doesn't work. I'm supplying culture from the aspx page's Culter and UICulture properties. I'm being very careful in choosing the correct file name, as that could be the issue,  but it just doesn't work. I also tried changing the culture in the backend code this way:

What's the problem in my javascript's code to get ClientID Property?



 Hi all.

I wirte a simple java script code to get ClientID of controls on the webform. The code is like:

<script type="text/javascript" language="javascript">

var butt = $find("<%= Button1.ClientID %>");



But when i run it , i have a problem. The probmel is:


Server Error in '/' Application.

The Controls collection cannot be modified because t

Problem in getting contol id in JavaScript


Hi want to get the Control ID in a javascrip so that i assign some value in it. 

document.getElementById('<%=hiddenSplitterCollapsedState.ClientID%>').value = mode

but on running .aspx page it's giving an Error

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


Problem changing/upgrading properties on WebParts that have already been deployed and added to Share

I have created two custom webparts which I deploy as a Feature within a Solution.  These webparts have been added to various pages on my site.  Due to design changes, I upgraded the webparts with some new functionality and some other changes to the webpart properties, such as the WebPart title, title icon and catalog icon.  After I have retracted/deleted the old solution and re-deployed the new solution (and activated the feature) the webparts have been upgraded fine, however, the webpart properties were not changed for any webparts that were already added to pages.  I can add new instances of the webparts and they have the updated properties (and also show correctly in the wp gallery and catalog). Is there a step I am missing in order to upgrade any webparts (namely the properties) that have already been added to pages?  Or is this something I have to take care of programmatically somehow to workaround the upgrade problem?

collapsiblepanel problem with javascript

Hiiii Coders, I have 4 collapsible panels on my page. Now i am using below javascript code for expanding and collapsing all the panels at the same time.  <script type="text/javascript"> function TogglePanels() { var panels = ["cpe1", "cpe2", "cpe3", "cpe4"]; for (var i = 0; i < panels.length; i++) $find(panels[i])._toggle(); } </script>here is my code for linkbutton (collapse all/expand all) and collapsiblepanel extenders<tr> <td align="right" valign="top"> <p style="text-align:right;"> <asp:LinkButton ID="L1" runat="server" Text="expand all" OnClientClick="TogglePanels();this.innerText=this.innerText=='expand all'?'collapse all':'expand all'; return false;"> </asp:LinkButton> </p> </td> </tr> <tr> <td> <cc1:CollapsiblePanelExtender ID="cpe1" runat="Server" TargetControlID="Panel1" ExpandControlID="Panel2" CollapseControlID="Panel2" BehaviorID="cpe1"

Problem with JavaScript on Textbox

 I have a textbox which is populated by an external javascript file which I cannot alter without affecting another part of the system. What I would like to do is once this textbox has a value to do something with it. The javascript that I want to use is fine, but it won't automatically when a value has populated it i.e. onchange. It will work when the event is onfocus. Is there away in which I can automatically fire off my javascript event when a value has entered the textbox from another piece of javascript code?  

problem with javascript in multiline textbox

 I am setting Maxlength of a textbox using javascript. Take maxlegth as 100.As we know Enter key is taking two char space. But i want to avoid this. i.e. if i press enter key after 96th char it should allow me to enter four more char where now it is allowing only 98. This is wat i am using  function textboxMultilineMaxNumber(txt,maxLen) { try { if(txt.value.length > (maxLen-1)) return false; } } catch(e){ } }

Changing Firefox values in about:config via Javascript

Hi WebGurus, I am currently facing a problem with Mozilla firefox JavaScript window.close() not working / does not work in firefox Is there any way of changing the values in about:config (specifically dom.allow_scripts_to_close_windows ) using Javascript, or via any other method when a page loads? Basically, I need a way of telling Firefox to close the window. If there is a better way of doing this please give me some guidelines regarding it. Thanks In Advance,Santosh

DetailsView edit problem after changing database

Hello!I had a DetailsView control for editing records in a Access 2003 database. I transfered the database to MS SQL 2008 and using the same code does not work - after clicking edit nothing happens (no error) and the record is not updated.ASP code:<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Urejanje kontaktnih podatkov </h2> <p> <asp:TextBox ID="txtKontaktID" Visible="false" runat="server"></asp:TextBox> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conKrik %>" ProviderName="<%$ ConnectionStrings:conKrik.ProviderName %>"  SelectCommand="SELECT tblKontakt.*, tblStranka.strSkrajsanNaziv FROM krik.tblKontakt INNER JOIN krik.tblStranka ON tblKontakt.StrankaID = tblStranka.StrankaID WHERE ([KontaktId] = @id)" UpdateCommand="UPDATE tblKontakt SET strIme = @strIme, strPriimek = @strPriimek, strPoslovnaEnota = @strPoslovnaEnota, strTelefon = @strTelefon, strFaks = @strFaks, strMobitel = @strMobitel, strEmail = @strEmail, rmkOpomba = @rmkO

javascript and c# problem

Hi all, Please help me with this issue, very urgent... Many thanks in advance.. I have a web form where I call a method, if page is not post back some thing like if (!IsPostBack)        FillCustomerDetails(); and FillCustomerDetails call a third party component and get a string back. I chop that string fill few asp:TextBox like  txtAddress.Text = obj.Address; txtPostCode.Text = obj.PostCode; etc... Now I have a  <input type="text" name="getAddress" id="getAddresst" onkeyup="keyUp(event)" /> control on the same page. So when user type in any thing in this Textbox, onkeyup is fired which is written in seperate .js file, which I have included on this page. Now this javascript Function onkeyup calls the c# code as document.getElementById('btnAddress').click(); (which is a <asp:Button>) So javascript is basically calling c# code and c# code is setting the values on <asp:TextBoxex> like  txtAddress.Text = obj.Address; txtPostCode.Text = obj.PostCode; Now my problem is, first time when page is loaded , it checks !IsPostBack and fills the TextBoxes txtAddress.Text = obj.Address; txtPostCode.Text = obj.PostCode; But when user types the new Address in the <input type="text" name="getAddress" id="getAddresst" onkeyup="

javascript onclick problem

I have 3textboxs namely txt1, txt2 and txt3. If  txt1 and txt2 not null, sum is calculated in txt3 when OnClick. Now the problem is that when OnClick to txt3,by default the  cursor is blink on left but I want to set on right. Eg, OnClick to txt3 it show 3251, and then the cursor is blink just befor the 3 but i want to blick after 1. Help me plz! Regards, Bedajit  

deserialize json string using javascript serializer problem



A json string was sent from client side to asmx web service.

Here json string is as below

"Name":"Ablation of Aflutter","BillingCode":"93651","ServiceCode":"1062","Value":1},
"Name":"Ablation of Atrial tachy","BillingCode":"93651","ServiceCode":"1062","Value":1},
"Name":"Ablation of AVN for CHB w/ or w/o temp pacer","BillingCode":"93650","ServiceCode":"1061","Value":1},
"Name":"Ablation of VT","BillingCode":"93652","ServiceCode":"1063","Value&q

Problem Creating Server Side Javascript


I have a custom control which creates client side Javascript in order for it to function. When the property .OnSelectScript is wrapped in an if...then that tests its length, the value of .OnSelectScript appears to be ignored when the Javascript is being generated. However, when I set the .text value of a test label to Javascript, it appears there. I have confirmed that the statement *does not* appear client side when I view the source for the page.

Property declaration for the control

    Public Property OnSelectScript() As String
            Return _OnSelectScript
        End Get
        Set(ByVal value As String)
            _OnSelectScript = value
        End Set
    End Property
    Private _OnSelectScript As String

Full SUB as designed

    Protected Sub Page_Load() Handles Me.Load

        Dim ClientSideJavaScript As New StringBuilder

        LabelSelectorTitle.Text = Me.Title
        Call LoadData()

        ClientSideJavaScript.Append("/*File: Test Selector.aspx.vb Sub: Page_Load()*/" & Chr(10))
        ClientSideJavaScript.Append("function setValue(ParentPopup, TargetDisplayControl, NewDisplayValue, TargetTextboxControl, NewKeyValue) {" & Chr(10))

problem in passing string array from activex dll to JavaScript


I do have a problem in passing string array from activex dll to JavaScript. i need to implement a methos as 

C# : 

Asp.Net Routing Css And Javascript Reference Problem


Hi All!

I have problem with url routing. I'm using Asp.Net theme in my project. My theme is messing up. I couldn't figure out how could i ignore the css and js files.

Web.Config theme reference;

<pages theme="Default" styleSheetTheme="Default" ></pages>

I've tried;


routes.RouteExistingFiles = false;//assume routes as my routecollection

and this;

            routes.Ignore("{*alljs}", new { alljs= @".*\.js(/.*)?" });
            routes.Ignore("{*allcss}", new { allcss= @".*\.css(/.*)?" });

and this;


but still doesn't work. Some of my friends told me to use ResolveClientUrl but i can't figure out how to reference it(because asp.net theme writes it for me already).

I need help. Thanks.

p.s sorry for my bad english

prevent postback javascript problem


i have the following example but i get error on GetPostBackEventReference line

value of tpe ...button cannot be converted to....

second question:where should i put this code? do i need just this code and nothing else

how should i for example delay for 20 seconds??

Dim sb As New System.Text.StringBuilder()
            sb.Append("if (typeof(Page_ClientValidate) == 'function') { ")
            sb.Append("if (Page_ClientValidate() == false) { return false; }} ")
            sb.Append("this.value = 'Please wait...';")
            sb.Append("this.disabled = true;")
            Me.btnAddPhotoComment.Attributes.Add("onclick", sb.ToString())



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend