State Management of View State_1 in ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewState1.aspx.cs" Inherits="ASPNETALL.ViewState1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Click Me" />
</div>
</form>
</body>
</html>
ViewState1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ASPNETALL
{
public partial class ViewState1 : System.Web.UI.Page
{
int ClickCount = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBox1.Text = "0";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
ClickCount = ClickCount + 1;
TextBox1.Text = ClickCount.ToString();
}
}
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Click Me" />
</div>
</form>
</body>
</html>
ViewState1.aspx.cs
using System;
namespace ASPNETALL
public partial class ViewState1 : System.Web.UI.Page
{
int ClickCount = 0;
if (!IsPostBack)
TextBox1.Text = "0";
}
protected void Button1_Click(object sender, EventArgs e)
ClickCount = ClickCount + 1;
TextBox1.Text = ClickCount.ToString();
}
}
}
0 comments
Post a Comment