Saturday, 3 October 2015

Asp.Net Page life-cycle event

Asp. Net Page Life Cycle events 


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="pagelifecycle.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

        <br />
        <br />
        <br />
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    
    </div>
    </form>
</body>
</html>






using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace pagelifecycle
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text += "Page Load event is occured....";

            if (Page.IsPostBack)
            {
                Label1.Text += "Page Potback even is handle....";
            
            }

        }
        protected void Page_Init(object sender, EventArgs e)
        {
            Label1.Text += "Page initialization event handled.<br/>";
        }

        protected void Page_Prerender(object sender, EventArgs e)
        {
            Label1.Text += "Page Prereder Event Occers";
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text += "  Click  event is occured....";

        }

        protected void Error(object sender, EventArgs e)
        {
            Label1.Text += "Helllooooo Error Occurd";
        
        
        }

    }
}

No comments:

Post a Comment