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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top