aspx页面上的超链接标记无法正常工作 [英] Hyperlink tag on aspx page not working

查看:72
本文介绍了aspx页面上的超链接标记无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在mt aspx页面中有一个超链接,如下所示:





Hi All,

I have a hyperlink in mt aspx page like this:


<asp:Repeater ID="Rpt" runat="server">
    <ItemTemplate>
        <p><%# Eval("Name") %>
        <asp:HyperLink  ID="Url" runat="server" Text ="<%# Eval("Url") %>"/>  </span></p>
    </ItemTemplate>
</asp:Repeater>





我可以拥有



as you can i have

<asp:HyperLink  ID="Url" runat="server" Text ="<%# Eval("SiteName") %>"/>  </span>





我正在尝试将siteName设置为用户将单击的文本区域。由于某种原因,我在该行上收到错误说:



I'm trying to set the "siteName" as text area where the user will click. for some reason i'm getting an error on that line saying:

Quote:

服务器标签不好形成。





我做错了什么或我能做些什么才能让这次跑步?



非常感谢。



我的尝试:



我还在想弄清楚为什么这不起作用



What am i doing wrong or what could i do to make this run?

Many thanks.

What I have tried:

I'm still trying figure out why this is not working

推荐答案

<asp:HyperLink  ID="Url" runat="server" Text ="<%# Eval("SiteName") %>"/> 





文本和评估都是在服务器端编译的,当你为两者()使用引号时,它会被混淆为到两者的界限,所以它认为Text属性是第一个和第二个引号之间的所有内容,所以;





"Text" and "Eval" are both compiled server-side and when you use quotes for both (") it gets confused as to the bounds of both, so it considers the Text attribute to be everything between the first and second quotes, so;

Text="<%#Eval("





解决方案非常简单,使用撇号表示外部文本,并引用内部Eval,因此.net知道适当的界限





The solution is fairly simple, use apostrophe for outer Text and quote for inner Eval so .net knows the proper boundaries

<asp:HyperLink  ID="Url" runat="server" Text ='<%# Eval("SiteName") %>'/> 


这篇关于aspx页面上的超链接标记无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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