[英]Dynamic links within a GridView in ASP.net/C#
I'm trying to create a GridView on page which lists the administrators for a system and there email address. 我正在尝试在页面上创建一个GridView,其中列出了系统管理员以及那里的电子邮件地址。
I would like to make it so that the administrators email address is displayed as a mail-to
link. 我要这样做,以便管理员的电子邮件地址显示为mail-to
链接。
At the moment I have got that working however the browser keeps trying to open the mail-to
address as if its a web address and of course returns a 404 error. 目前,我已经可以正常工作了,但是浏览器一直在尝试打开mail-to
地址,就像它的网址一样,当然返回了404错误。
Is there a way to stop the browser redirecting to the mail-to
address? 有没有一种方法可以阻止浏览器重定向到mail-to
地址?
I am using a hyperlink as an item template in the asp definition of the GridView, like this : 我在GridView的asp定义中使用超链接作为项目模板,如下所示:
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink2" runat="server" Text='<%# Eval("E-mail") %>'
NavigateUrl='<%# Eval("E-mail", "mailto:{0}") %>' Target=""></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
As I mentioned previously, the code does generate the mail-to
link as expected but the browser keeps trying to redirect to it and I would like it not to do that and just stay on the same page instead. 如前所述,代码确实按预期生成了mail-to
链接,但是浏览器一直在尝试重定向到该链接,我希望它不这样做,而只停留在同一页面上。
Obviously I am using ASP.net and C# for this project. 显然,我正在为此项目使用ASP.net和C#。
请尝试以下操作,可能会帮助您...
NavigateUrl='<%# String.Format("mailto:{0}", Eval("E-mail"))%>'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.