How to avoid execution of page_load event before click event of a


G

Guest

I have a page where I initialize a textbox.text value in the page_load event
.. I have also a button where I want to do something with the value of the
textbox.text . The user can change manually the value of the textbox. I have
noticed that the textbox.Text property has always the initial value inside
the the click event of the buttom because the page_load event is executed
always before the click event. Any way to avoid this?

Thanks
 
Ad

Advertisements

S

sirfunusa

That is incorrect. The click event (on the server) happens first,
before the page is rendered back to the client. Post the minimum code
necessary here to demonstrate your problem.
 
S

sirfunusa

Oh, perhaps you mean the "server" page load happens first, which is
true. Then use

If Not Page.IsPostBack...
.....

End if
 
R

rachana

use IsPostback.

if(!IsPostBack)
{
// code to initialize textbox
}

Now when the button is clicked, page is reloaded but as it is being
posted back the code in if block won't execute, so textbox.text won't
be reinitialized.
 
Ad

Advertisements

Ad

Advertisements


Top