Button causes Form_Load to fire, before Button_Click

Discussion in 'ASP .Net' started by Paul Aspinall, Aug 12, 2003.

  1. Hi

    I have a form with a button on it.

    It seems that when I click the button, it causes Form_load to fire, before
    the Button_Click procedure

    Does anyone know why??

    Thanks
     
    Paul Aspinall, Aug 12, 2003
    #1
    1. Advertisements

  2. Paul Aspinall

    Duray AKAR Guest

    This is the firing order of events:

    Page_Init
    Page_Load
    Button_Click
    Page_PreRender
    <% %> codes on the aspx page.

    If you are trying to avoid calling the same code everytime
    the page is posted back use :

    if (!Page.IsPostBack)
    {
    // code to execute just on the first load
    }

    or

    If Not Page.IsPostBack Then
    ' code to execute just on the first load
    End If

    Hope It Helps

    Duray AKAR
     
    Duray AKAR, Aug 12, 2003
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.