HttpUtility.UrlEncode()在asp.net 4.0中不起作用 [英] HttpUtility.UrlEncode() is not working in asp.net 4.0

查看:401
本文介绍了HttpUtility.UrlEncode()在asp.net 4.0中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..



我正在尝试使用HttpUtility.UrlEncode编码网址,

但无法使其正常工作。 HyperLink控件位于gridview的

模板字段中。



任何人都可以帮我解决这个问题吗?



我试过更改目标应用程序并添加

System.Web参考项目但仍然无法编码

网址。



请指导我。



以下是我的代码的一部分: -



 <   asp:HyperLink     ID   =  lnkDetailsPage    runat   =  server    NavigateUrl   ='  <%#string.Format(  〜/ YellowPages / YellowDetailView.aspx?CustomerId = {0},HttpUtility.UrlEncode(Eval(   CustomerId)。ToString()))%>' >  <   / asp:HyperLink  >  







谢谢提前。

解决方案

hi
试试这个..



 <   asp:HyperLink    < span class =code-attribute> ID   =  lnkDetailsPage   文字  = 点击此处    runat   =  server    NavigateUrl   ='  <% 〜/ YellowPages / YellowDetailView.aspx?CustomerId = + HttpUtility.UrlEncode(Eval(  CustomerId)。ToString())%>' >  
< / asp:HyperLink >





Text =click here







无论何时使用超链接,都应指定文本值。



如果 Text 值为空,则链接不会出现在屏幕上。


Hi..

I am trying to encode the url using HttpUtility.UrlEncode,
but not able to make it work. HyperLink control is in the
template field of gridview.

Can anyone please help me out with this??

I have tried changing the target application and by adding
System.Web reference to project but still not able to Encode
the url.

Please guide me.

Following is part of my code:-

<asp:HyperLink ID="lnkDetailsPage" runat="server" NavigateUrl='<%# string.Format("~/YellowPages/YellowDetailView.aspx?CustomerId={0}",HttpUtility.UrlEncode(Eval("CustomerId").ToString())) %>'></asp:HyperLink>




Thanks in advance.

解决方案

hi Try this..

<asp:HyperLink ID="lnkDetailsPage" Text="click here" runat="server" NavigateUrl='<%# "~/YellowPages/YellowDetailView.aspx?CustomerId=" + HttpUtility.UrlEncode(Eval("CustomerId").ToString())  %>'>
                   </asp:HyperLink>



Text="click here"



whenever you are using Hyperlink you should assign the Text value.

if the Text value is empty , then the link wont appear on the screen.


这篇关于HttpUtility.UrlEncode()在asp.net 4.0中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆