IsPostBack Property In ASP.NET Web Forms | ASP.NET Web Forms Tutorials | ASP.NET
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
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//When page load first time at that time only "IsPostBack" value will be false
//When page will load second time or after that any time at that time only "IsPostBack" value will be true
//if (IsPostBack)
//{
// Response.Write("THIS IS POST BACK REQUEST !!");
//}
//if (!IsPostBack)
//{
// Response.Write("THIS IS NOT POST BACK REQUEST !!");
//}
if (!IsPostBack)
{
AddListBoxItems();
}
}
void AddListBoxItems()
{
ListBox1.Items.Add("Item 1");
ListBox1.Items.Add("Item 2");
ListBox1.Items.Add("Item 3");
}
}
}
Above File is is_post_back\WebForm1.aspx.cs
Comments
Post a Comment