日期:2014-05-19  浏览次数:21008 次

问大家一个问题关于Server.UrlEncode
<a   href= "../index.aspx?id= <%#   Server.UrlEncode( "kkkkkk ");%> ">
为什么向上面写不对那,那位能告诉我正确写法那。谢谢了

------解决方案--------------------
Server.UrlEncode( "kkkkkk ") 有这个变量么
------解决方案--------------------
<a href= "../index.aspx?id= <%# System.Web.HttpUtility.UrlEncode( "kkkkkk ");%> ">

------解决方案--------------------
直接用encodeURI
<a href= "../index.aspx?id=encodeURI( "kkkkkk ") />
------解决方案--------------------
不用绑定,直接赋值。绑定要显示调用Page.Bind()才有效,麻烦。
对Server的访问不能那样,UrlEncode是static方法,Server是HttpUtility的实例,不能访问。
<a href= "../index.aspx?id= <%= System.Web.HttpUtility.UrlEncode( "kkkkkk ") %> ">