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

    Button Event Working Lifecycle

    Hi, Life cycle of button event and how its working, how request sent to page and database. this my interview ques.
  • #762238
    Hi Rajasekaran,

    First Page life cycle will perform, and then button event will perform. this is what happening for each and every request, first it should perform page life cycle events.

    Hope this will helpful to you..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #762251
    Hello G Rajasekaran,

    You can use the page prerender event. this fire after the control event in the page lifecycle.

    You can solve your problem by below code, use this end of button_click block

    Response.Redirect(HttpContext.Current.Request.Path);


    Hope this will work for you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #762254
    Hi

    Page lifecycle is follow

    1.Page_Init
    2.Page_InitComplete
    3.PreLoad
    4.Page_Load
    5.Page_Render

    So when you click button First invokes pageload event so they focusing this

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762255
    Hi

    You can go through Below links for Page life cycle with Snapshots

    http://www.c-sharpcorner.com/UploadFile/8911c4/page-life-cycle-with-examples-in-Asp-Net/

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762257
    Hello Kumar,

    He asked for Button Event Not Page Event Life Cycle.

    I hope you read the question carefully.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #762305
    Hi

    This question is closely related and totally related to page life cycle.
    Button click event occurs after the page load event.

    Normal page load will have the following lifecycle.
    1.PreInit
    2.Init
    3.InitComplete
    4.PreLoad
    5.Load
    6.LoadComplete
    7.PreRender
    8.SaveStateComplete
    9.Render

    If a button is clicked then the events will have the following changes.

    1.PreInit
    2.Init
    3.InitComplete
    4.PreLoad
    5.Load
    6.LoadComplete
    7.PreRender
    8.PreLoad
    9.Load
    10.Btn_click event
    11.LoadComplete
    12.PreRender
    13.SaveStateComplete
    14.Render

    Regards

    Sridhar Thota.

    Sridhar Thota.
    Editor: DNS Forum.

  • #762306
    Hi Nirav,

    for any event first page life cycle will perform then after that particular event will trigger.

    In this scenario, page life cycle will perform first then after button event will perform.

    Hope you understood...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #762561
    Hi

    If you want to know the button life cycle, just make a sample application and write all the pagelife cycle events and drag a button control on to the form.
    Now put break point at PreInit event and check line by line with button click and with out button click.
    Then you can know what is happening after we press button.

    Regards

    Sai Krishna Reddy.


Sign In to post your comments