Question : hidden label still accessable from codebehind? but not in javascript... how does that work?

Hi, this is probably a stupid question, but I was looking at some of my old code and was surprised to find that it worked when i thought that it shouldn't work.

Basically, I have some hidden labels (which are never set to visible) and when I click some button on the webpage, the labels are set to some value, which i can then read later on. Thing is, at some point i had gotten it into my head that i couldn't do this. I think it was when i was working with javascript... and found that a hidden control cannot be accessed in javascript... because it is not rendered onto the page. If the control is hidden, it basically doesn't exist on the page. And, when i look at the source code in IE browser, I can indeed see that those labels do not exist on the page.

So then I'm asking myself... why does this code actually work when setting and reading from the codebehind (i.e. postback to server). How is it that the server can read these controls when they are not actually on the page also and then set them to something else? Is this some kind of viewstate thing I don't understand?

Thanks, Aiden

Answer : hidden label still accessable from codebehind? but not in javascript... how does that work?

yes. Control is there with visibility hidden. This is the reason you can access it. Buts its as its visibility id false it is not rendered on browser. (Check designer file if you are using above 2.0 framework.)

This is the reason and due to this you can again set that control visible from code behind.
Only main point is as it is not rendered, you can not access it from javascript.
Random Solutions  
 
programming4us programming4us