IsPostBack Property In ASP.NET Web Forms | ASP.NET Web Forms Tutorials | ASP.NET

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="is_post_back_practice.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:ListBox ID="ListBox1" runat="server" Height="132px" Width="101px"></asp:ListBox>

            <br />

            <br />

            <asp:Button ID="Button1" runat="server" Text="CLICK"/>

        </div>

    </form>

</body>

</html>

Above File is is_post_back_practice\WebForm1.aspx














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

namespace is_post_back_practice
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            //    Response.Write("THIS IS POST BACK REQUEST !!");
            //}

            if (!IsPostBack)
            {
                AddListBoxItems();
            }
        }

        void AddListBoxItems()
        {
            ListBox1.Items.Add("Item 1");
            ListBox1.Items.Add("Item 2");
            ListBox1.Items.Add("Item 3");
            ListBox1.Items.Add("Item 4");
        }
    }
}
Above File is is_post_back_practice\WebForm1.aspx.cs





Comments

Popular posts from this blog

Range Validator Control In ASP.NET Web forms | Form Validation | ASP.NET Web forms

Query String In ASP.NET Web Forms | State Management | ASP.NET | Web Forms

Validation Summary Control In ASP.NET Web forms | Form Validation | ASP.NET