using HTTP Get in Asp.net
Here is the code for transferring more than one value via the HTTP query string. The first code is on default2 in the Confirm button.
protected void btnConfirm_Click(object sender, EventArgs e) { Response.Redirect("Default3.aspx?lastname="+ txtLastName.Text + "&firstname=" + txtFirstName.Text); }
The second part, reading the values from the string is in the page load event of Default3
string lastName = Request.QueryString["lastname"]; string firstName = Request.QueryString["firstname"]; Label1.Text = "Thank you for submission, " + lastName + ", " + firstName;
Things to think about
The pattern is more important than the detail. You can always look up the details. So what is the patter?
The Master page is a template that lets you create a consistent look and feel for a web site.
When you use a master page, you want to add content pages not web forms. Content pages will use the master pages, web forms are independent.
The assignment is basically moving the content of a form from one page to another. The thing to take away from it, is that it is better to create an object to store all the information (our customer class) and move one thing, rather than move each value separately.
Web pages are stateless, meaning they don't retain values. Each page is also independent of the every other page. Generally, one web page cannot see what's on another. So to move things you have to use a Session variable or a cookie to store the value and then call that session or cookie on the next page. (the same holds true to save a value between page refreshes which happen with each page button click)
No comments:
Post a Comment