Add QueryString to send back?

Can I add to a QueryString in Postback? If so, how do you do it in the world?

Thanks!

+4
source share
4 answers

Not that I knew. You do not have much control over postbacks with ASP.NET. For a different type of application, you can send messages to another page. I know that there is a mechanism for publishing to another page in asp.net - but I never had to.

What you are trying to accomplish is perhaps another way.

0
source

This can be done using Response.Redirect() :

 Response.Redirect(String.Format("{0}?querystring=value", Request.CurrentExecutionFilePath)); 

However, I do not think it is possible to associate a query string with a URL without reloading the page again.

The query string in the url is not like an anchor. It may have an effects server side and is classified as a different URL from one without a query string. Therefore, it is not possible to bind a query string without reloading the page.

0
source
  • If you go to another page, you can use response.redirect ("page path" + query string) to add a query string.
  • If you’re on the same page and want to do this by clicking the button that is already sending the page, you can use the postbackurl button properties and specify the URL of the same page and add a query string there, because the button has already sent the page " PostbackUrl "will not publish it again, but it will change the url (Now with your updated query string).

The following is an example of doing this on an html page, but you can do it with code too.

 <asp:ImageButton ID="ibRestrictAcct" runat="server" AlternateText="Restrict Account" OnClick="ibRestrictAcct_Click" PostBackUrl="~/MyPage.aspx?Action=Restrict" /> 
0
source

Are you looking for something like this (if you are not redirecting)?

  Request.QueryString.Add("Name","Value"); 
-1
source

Source: https://habr.com/ru/post/1384360/


All Articles