Passing parameters from one page to another - .NET
Passing parameters from one page to another is a very common task in Web development. Granted, its importance and frequency has faded a bit with ASP.NET's inherent preference for postback forms, but regardless, there are still many situations in which you need to pass data from one Web page to another. One of the simplest and most efficient ways of passing parameters among pages is to use the querystring. Unfortunately, packing data into the querystring via string manipulations can quickly lead to cumbersome and often difficult to maintain code, especially as the parameter list grows. Consider the following C# code to pass a number of parameters from on the querystring:
string URL = "Page2.aspx?FirstName=" + txtFirstName.Text + "&MiddleName=" + txtMiddleName.Text + "&LastName=" + txtLastName.LastName + "&DOB=" + Session["txtDOB"].ToString() + "&State=" + Request.Form.Get("hiddenState"); Response.Redirect(URL);
This code is somewhat unclear, making it hard to see at a glance what the variable names on the querystring are, and what values are being passed for each variable. Further, changes to variables that are passed are more cumbersome and prone to error than they need to be.
This article uses a custom class. Read more
Can't find what you're looking for? Try Google Search!
Comments on "Passing parameters from one page to another - .NET"