Sunday 22 December 2013

State Management Technique

State management Technique is a process by which we maintain the state & page into over multiple request for the same of different page.
(1) Cookies in Asp.Net:-   There are Two types of cookies in Asp.Net

  • Session Cookie/Non persistence Cookie
  • Persistence Cookie

For more Detail About Cookie Click here And For Session Click here

On the Web Form 1
protected void btnclick_click (object sender,Event args e)
{
HttpCookie M1 = new Httpcookie["userinfo"];
M1["name"] = textbox1.text;
M1["email"] = textbox2.text;
Responce.cookies.Add("M1");
Responce.redirect("webform2.aspx");
}



On the Web Form 2
protected void Page_Load (object sender,Event args e)
{
HttpCookie M1 = Request.cookies["userinfo"];
if(Cookie ! = null)
lable1.text = M1["name"] ;
lable2.text = M1["email"];

}




(2) Query String Management System:-

For more Detail About Cookie Click here

On WebForm 1
{
protected void btnclick_click (object sender,Event args e)
Responce.Redirect ( "webform2.aspx?username+" + textbox1.text + "& useremail + " textbox2.text);
}

On WebForm 2

protected void Page_Load (object sender,Event args e)
{
lable1.text = Request.querystring [ "ussername"];
lable2.text = Request.querystring [ "usseremail"];
}


(3) Session State Management System:-

On WebForm 1
{
protected void btnclick_click (object sender,Event args e)
Session [ "username"] = textbox1.text;
Session [ "useremail"] = textbox2.text;
}

On WebForm 2

protected void Page_Load (object sender,Event args e)
{
if ( Session["username"] ! = null)
{
lable1.text = Session [ "username"].ToString;
}

if ( Session["useremail"] ! = null)
{
lable2.text = Session [ "useremail"].ToString;
}
}

(4) Application State Management System:-

On WebForm 1
{
protected void btnclick_click (object sender,Event args e)
Application [ "username"] = textbox1.text;
Application [ "useremail"] = textbox2.text;
}

On WebForm 2

protected void Page_Load (object sender,Event args e)

{
lable1.text = Application [ "username"].ToString();
lable2.text = Application [ "useremail"].ToString();

}

(5) View State/Hidden Field Management System:-

It is used to maintain the state of controls during Page Post Back and if we save any Control value or anything in View state we can access those value through out the page whenever it  require for that check

For more Detail About View State  Click Here




1 comment:

  1. Hi, I am facing the same issue. I am unable to install .NET Framework 3.5. I tried your solution but I do not know what I have to give in Source. Do I have to give the .NET Framework set up source or the source of my application which requires .NET. Please me with a solution as soon as possible.

    Thanks!

    dotnet training in chennai


    ReplyDelete

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...