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:

image

 

After click on the Go button:

 

image

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.