Url Postback Editing

Suppose I have a URL: http: // localhost: 4647 / Project / MyList.aspx .

In postback, I want to add some parameter to the URL (pageNo = 4): http: // localhost: 4647 / Project / MyList.aspx? PageNo = 4

Can I add "pageNo = 4" to the url after the postback as shown above? If so, tell me how to do it.

+3
source share
3 answers

You cannot change the client URL from server code without redirecting.

URL- . (HTTP- URL-, , . .)

, - - .

+4

form method define get hidden input 4 pageNo. , : http://localhost:4647/Project/MyList.aspx.

<html>
<body>
<form method="get">
  <input name="pageNo" type="hidden" value="4"/>
  <input type="submit" value="submit"/>
</form>
</body>
</html>

, , MyList.aspx, action . Default.aspx

<html>
<body>
<form method="get" action="MyList.aspx">
  <input name="pageNo" type="hidden" value="4"/>
  <input type="submit" value="submit"/>
</form>
</body>
</html>

action form.

, get post

0

Another thing you can try: you can use hidden input and set the value on the server side and read it on the client side.

Server:

hdnPageNumber.Value = "4";

Customer:

<asp:HiddenField id="hdnPageNumber" runat="server" ClientIDMode="Static"  />




if ($('#hdnPageNumber').val() == "4")
{
....
}
0
source

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


All Articles