Saturday, October 30, 2021

What is Session, query string and view state

 Session is a state management technique. Session values are stored on server.

Session["name"] = "yash";

lblName.Text = Session["name"].ToString();


--------------------------------------------

Query String is helpful when we want to transfer a value from one page to another

Query string is a state management technique. Query string values are stored on client side. We can pass query string in URL by question mark(?)

example

Response.Redirect("Test1.aspx?ID="+ Guid.NewGuid());


and ID can be used in another aspx Page.

lblID.Text = Request.QueryString["ID"].ToString();

--------------------------------------------------


View state is a state management technique. View state values are stored on client side.

ViewState["name"] = "yash";

and we can use this view state in same page.

lblName.Text = ViewState["name"] ;


references:-

https://www.c-sharpcorner.com/UploadFile/nipuntomar/state-management-in-Asp-Net/

https://www.c-sharpcorner.com/UploadFile/225740/introduction-of-session-in-Asp-Net/


https://www.c-sharpcorner.com/UploadFile/ca2535/query-string-in-Asp-Net/

https://www.c-sharpcorner.com/UploadFile/225740/what-is-view-state-and-how-it-works-in-Asp-Net53/

No comments:

Post a Comment