Javascript variables look like assignable, but in reality they are not

I have some RegisterStartupScript in my C # code that assigns some values ​​to some fields to some panel controls when it's open.

The controls in the panel show as if their values ​​were assigned properly, but in reality they work as if they were never assigned, I checked this in the dynamic view of my aspx page.

For example: this is an instruction for one of the startup scripts: document.getElementById ("MainContent_Textbox1215"). value = 'CALL CENTER' ;, and in fact when I see this textbox on the screen, it displays the call center.

But at the same time, it is what is really in the code and what the application interprets for future operations, taken from the dynamic view of that particular page.

<input name="ctl00$MainContent$Textbox1215" type="text" id="MainContent_Textbox1215" class="listBox" style="width:50%;" />

      

Things like this happen with radio exchanges, so even if the screen appears to be the one that is selected for real, the one that is defined as the default, and probably with all types of controls.

It looks like a real value has never been assigned to a textBox or radiobutton ... This is the strangest thing I've ever seen in programming, hopefully you can guide me on what to do.

+3


source to share


1 answer


   Even i have faced such a problem once while working with javascript and dotnet.
   What i can say is that you might not have specified the **Value** attribute of
 the textbox in you html that is the reason it is not showing it in your dynamic 
aspx page but the value has been assigned and you can use it anywhere you want.
 This you can verify even with ha plain html page there also i faced the same
 thing. But if you have specified some value for the Value attribute you will see
 old value in the html source but if you try to access it using javascript it will 
show you the new value. I cant figure out the reason behind this behaviour but 
this is what i have experienced.

      



+1


source







All Articles