0

I have a button that calls a function in the code behind which simply updates the text inside a label. I have a URL that looks like this:

http://my-url.com?lang=en

If I change the query string, to say lang=fr then do not submit the URL (i.e. press enter) but instead press the button, how do I get this new value? Request.QueryString["lang"]; will return the value of the lasted submitted URL i.e. will return lang=en and not lang=fr

Thanks.

user3873171
  • 77
  • 1
  • 8

1 Answers1

1

Based on your code examples, I understand that you don't any postback you just change it in JS so it is clear you couldn't get new value in code-behind

To get new query string in server-side you should submit Url or if you wanna work with query string in JS then take a look at this links:

Get and Set query String in JS

JavaScript query string

Retrieving Query String Values in ASP.NET and Javascript

Hope thi will help you.

Community
  • 1
  • 1
Aria
  • 3,724
  • 1
  • 20
  • 51