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

Discussion in 'ASP .Net' started by =?Utf-8?B?Sm9zZVZhbGVuY2lh?=, Apr 3, 2006.

  1. 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
    =?Utf-8?B?Sm9zZVZhbGVuY2lh?=, Apr 3, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?Sm9zZVZhbGVuY2lh?=

    sirfunusa Guest

    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.
    sirfunusa, Apr 3, 2006
    #2
    1. Advertising

  3. =?Utf-8?B?Sm9zZVZhbGVuY2lh?=

    sirfunusa Guest

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

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

    End if
    sirfunusa, Apr 3, 2006
    #3
  4. =?Utf-8?B?Sm9zZVZhbGVuY2lh?=

    rachana Guest

    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.
    rachana, Apr 3, 2006
    #4
  5. Re: How to avoid execution of page_load event before click event o

    Thank you, that's what I need

    "sirfunusa" wrote:

    > Oh, perhaps you mean the "server" page load happens first, which is
    > true. Then use
    >
    > If Not Page.IsPostBack...
    > .....
    >
    > End if
    >
    >
    =?Utf-8?B?Sm9zZVZhbGVuY2lh?=, Apr 4, 2006
    #5
  6. Re: How to avoid execution of page_load event before click event o

    Thank you, that's what I need

    "rachana" wrote:

    > 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.
    >
    >
    =?Utf-8?B?Sm9zZVZhbGVuY2lh?=, Apr 4, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Purvi T
    Replies:
    0
    Views:
    820
    Purvi T
    Oct 19, 2004
  2. Ryan Ternier
    Replies:
    4
    Views:
    3,955
    Cowboy \(Gregory A. Beamer\) [MVP]
    Jul 29, 2004
  3. rockdale
    Replies:
    1
    Views:
    648
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Nov 16, 2006
  4. DC
    Replies:
    4
    Views:
    403
  5. Mark

    Button-click fire before or after page_load?

    Mark, Mar 2, 2004, in forum: ASP .Net Building Controls
    Replies:
    7
    Views:
    197
    Alessandro Zifiglio
    Mar 6, 2004
Loading...

Share This Page