Are we passing data in URLs that are generally xx.aspx? a=1&b=2&c= you pass the Chinese in this way is OK, we use request.querystring["C" in the background to accept it. The browser will automatically decode it for us.
If the parameter is too many, so stitching is not very convenient, this time we can put all the parameters and values in the JSON format, and then the value xx.aspx?json={"1", 1, "2", "2"}, if written like this, When accepted, only one parameter is accepted.
JSON in the URL to the value of considerations:
1, the JSON string needs to be encoded and then passed
2, if the JSON string appears in Chinese, we can not decode in the background
View Listjson
For example:
<div> <a href="Webform1.aspx?jsondata=<%=json%>"> Background Write josn value </a> <div id="Test"style="width:150px; height:150px; border:solid 1px red;">JS Transfer value</div> </div> <script src=".. /jquery.min.js"></script> <script> $("#test"). Click (function () {varJSON ={Name:"Li MoU", Age: A, like:"Movies"} document.location.href="webform1.aspx?jsondata="+ Escape (json.stringify (JSON));//encoding pass -through value }); </script>
Page effects
Accept page:
Background acceptance
We can not decode Chinese, only use data["Name" method to get Chinese.
JS Accept
Effect:
① Click Background to pass JSON background decoding Chinese does not come out
② Click JS to pass the value of the background can decode the success
We can then use JS to get this JSON, and turn it into an object
Passing JSON data in a URL