Accesssing TextBox value in Init Event

As per ASP.net Page Lifecycle, Events that actually wire up Server Controls and load their viewstate, take place, quite after Init. However, one thing to remember is that even in Init Request object is available.

Hence, if you are aware of textbox control then you can access it using Request["textBoxName"].

Ideally you would use HTMLcontrol instead of ASP.net server control Like:

<input type="text" id="myTextbox" value="<%=SomeValueFromServerSide%>">

This textbox then can easily be accessed in Init using
var textBoxValue = Request["myTextBox"]

Comments

Popular posts from this blog

How to construct a B+ tree with example

How to show only month and year fields in android Date-picker?

Visitor Counter Script Using PHP