You must Sign In to post a response.
  • Category: ASP.NET

    Page_load event fired twice

    Hi..

    On clicking the button for the first time in asp.net application, page_load is fired once, but at the 2nd click, page_load is fired twice. Using VS 2008 (version 3.5).

    Please guide

    Thanks!!
  • #594999
    Hi,

    Page_Load() event would fire on every post back of the page.

    If you have a code that you do not want to execute it again on post back then you can just handle it using ispostback property.

    If(ispostback)
    {
    // Put here the code that you want to execute only on every postback.
    }

    if(!ispostback)
    {
    // Put here the code that you want to execute only once at time of first time page load.
    }

    Except this nothing is the trick..

    If still you have some problem then post your code here please so that we can give you a proper solution.

    Regards
    Pankaj Rajput

  • #595003
    Hi,

    Can you post your page_load code. How did you identified that your page is loading two times?
    It is hard to suggest anything without seeing your code.


    Regards,
    Asheej T K

  • #595005
    HI,

    Can you please post your code over here, So that we can suggest something.

    Thanks,
    Senthilnathan

  • #595025
    Hi,

    Keep Your function in

    if (!IsPostBack)
    {


    }

    But strnage clicking on button Page Load is 2 times???

    Please post your code

    Cheers!!!!

    Rajesh Kumar Parbat
    (Mentor,Editor,MVM)

  • #595151
    just put


    if(!IspostBack)
    {
    //your code
    }



    hope this will help you


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.