Different Methods to Pass Values between Web FormsCross page posting means to post data from one page to another page.this is an important concept in web development.there are many methods to perform this task.some of Them are following. Cookies:A small piece of information or message sent by the web server to User's web browser during a request, which is stored on user's system in the form of a text file(mostly as notepad file). How to use a cookie. HttpCookie samplecookie = new HttpCookie("mycookie"); samplecookie.Value = TextBox1.Text; samplecookie.Expires = DateTime.Now.AddHours(1); Response.Cookies.Add(samplecookie); Response.Redirect("default2.aspx"); ON Second pageRetrive value using cookies.Label1.Text = Request.Cookies["mycookie"].Value; Query Stringthis is another way to pass value between pages.in it we have to use a question mark (?) as separator. "&" is use to pass multiple query strings. how to use querystring Response.Redirect("default2.aspx?pass="+TextBox2.Text); Retrieve value using Querystring Label2.Text = Request.QueryString["pass"] Sessionsit is server side state management method.this is most secure and most acceptable way of cross page postinghow to use session on page.Session["user"] = txtName.Text; on second pagestring str=Session["user"].ToString(); |
basically this is a a my own blog to help ma students and friends with sharing useful information with the. information regarding C language code. .net applications, .net projects. general technical information. notes.
Sunday, 13 November 2011
Different Methods to Pass Values between Web Forms
Labels:
.Net
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment