Nic*_*ahn 4 javascript c# asp.net jquery urlencode
如何使用JavaScript安全地对URL进行编码,以便将其放入GET字符串?
这是我在jQuery中所做的:
var url = "mynewpage.aspx?id=1234";
$(location).attr('href', url);
Run Code Online (Sandbox Code Playgroud)
在ASP.NET page_load中,我正在读这个:
_string _id = Request.QueryString["id"].ToString();
Run Code Online (Sandbox Code Playgroud)
如何在jQuery/JavaScript中编码id并在ASP.NET(C#)中解码?
使用encodeURIComponent(str)JavaScript中的编码和使用HttpUtility.UrlDecode解码在ASP.NET的URL.
在JavaScript中:
var url = "mynewpage.aspx?id="+encodeURIComponent(idvalue);
$(location).attr('href', url);
Run Code Online (Sandbox Code Playgroud)
在ASP.NET中
_string _id = HttpUtility.UrlDecode(Request.QueryString["id"]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14666 次 |
| 最近记录: |