In client-side state management, the state of value is maintained(Stored) on the client machine for further use.
1. Hidden Field 2. Query String
3.
View State 4. Cookies
Hidden Field
Using Hidden Field we can maintain
the value between the roundtrip.
1. Hidden Field is an ASP Control.
Example:-
>> In StateManagementDemo2.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div><asp:HiddenField ID="hdfCount" Value="0" runat="server" />
<asp:Button ID="btnClick" Text="Click Me" OnClick="btnClick_Click" runat="server"/>
<asp:Button ID="btnGo" Text="Go" PostBackUrl="~/RedirectedForm.aspx" runat="server" />
</div>
</form>
</body>
</html>
>> In StateManagementDemo2.aspx.cs
using System;
namespace MyPalmBookWeb
{
public partial class StatemanagementDemo2 : System.Web.UI.Page
{
int i = 0;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnClick_Click(object sender, EventArgs e)
{
// i +=1;
i = int.Parse(hdfCount.Value) + 1;
Response.Write(i);
hdfCount.Value = i.ToString();
}
}
}
>> In RedirectedForm.aspx.cs
using System;
namespace MyPalmBookWeb
{
public partial class RedirectedForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string hdfval = Request.Form["hdfCount"];
Response.Write("You have
clicked the button :"+hdfval +"times");
}
}
}
Watch the video tutorial here
Watch the video tutorial here
For Query string Click here.