我可以使用JavaScript编码网址吗? [英] Can I Encode Url With JavaScript?
本文介绍了我可以使用JavaScript编码网址吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
hi all
$.ajax({
url: 'GetTagComment.aspx?Tag=' + tagName,
success: function (data) {
$('.TagComment').html(data);
}
});
例如(如果tagName == C#),则在GetTagComment.aspx的PageLoad中:
for Example (If tagName== C#)then In PageLoad Of GetTagComment.aspx:
string TagName = Request.QueryString["Tag"];
我看到TagName是C,因为#应该编码,而我却不知道如何编码?!
请帮助我
非常感谢
i See TagName is C,Beacuse # Should Encode and I downt Know How to Encode It?!
Please Help me
thanks so much
推荐答案
.ajax({ 网址:' GetTagComment.aspx?Tag =' + tagName, 成功:函数(数据){
.ajax({ url: 'GetTagComment.aspx?Tag=' + tagName, success: function (data) {
(' .TagComment').html(数据); } });
('.TagComment').html(data); } });
例如(如果tagName == C#),则在GetTagComment.aspx的PageLoad中:
for Example (If tagName== C#)then In PageLoad Of GetTagComment.aspx:
string TagName = Request.QueryString["Tag"];
我看到TagName是C,因为#应该编码,而我却不知道如何编码?!
请帮助我
非常感谢
i See TagName is C,Beacuse # Should Encode and I downt Know How to Encode It?!
Please Help me
thanks so much
编码:
Hi,
Encoding:
string result = HttpUtility.UrlEncode(tagName);
Response.Redirect("*.aspx?Tag=" + result);
解码:
Decoding:
string result = HttpUtility.UrlDecode(Request.QueryString["Tag"].ToString());
这篇关于我可以使用JavaScript编码网址吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文