IsPostBack.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="IsPostBack.aspx.cs" Inherits="Learningneverend.IsPostBack" %>
<!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"></asp:ListBox>
<br\ />
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
IsPostBack.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Learningneverend
{
public partial class IsPostBack : 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");
}
}
}
0 Comments