12 December, 2011
0 Comments
1 category
If you want to post back to the same page, only adjusting the query string parameters, you can use the following code:
using System; using System.Collections.Specialized; using System.Web; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void GoLinkButton_Click(object sender, EventArgs e) { // Copy the original querystring parameters. NameValueCollection queryString = HttpUtility.ParseQueryString(Request.QueryString.ToString()); // Set the first parameter (it will be added if it does not exist). queryString.Set("myparameter1", "1000"); // Postback to the same page, with adjusted querystring parameters. Response.Redirect(string.Format("{0}?{1}", Request.Url, queryString.ToString())); } } }
Before click on the Go button:
After click on the Go button:
Category: Uncategorized