0

在列表视图事件的 ListView1_ItemDataBound 上,我像这样创建literal.text ...

<span style=&quot;position:relative;&quot;>
style="position:relative">
<span id=&quot;term1&quot; class=&quot;popup&quot;>This id="term1" class="popup">This is the answer!</span>
<a href=&quot;javascript:void(0);&quot;onMouseover=&quot;ShowPop('term1');&quot; onMouseout=&quot;HidePop('term1');&quot;>Show href="javascript:void(0);"onMouseover="ShowPop('term1')" onMouseout="HidePop('term1')">Show me the answer</a></span>

问题是文本没有按应有的方式呈现。在将鼠标悬停在文字控件上时,网址为

http://localhost:1391/"javascript:void(0);"onMouseover="ShowPop('term1');"

那么这里发生了什么?我错过了什么?

UPDATE1: 这是来自浏览器的来源

 <span style=&quot;position:relative;&quot;> <span id=&quot;term1&quot; class=&quot;popup&quot;>This is the answer!</span> <a href=&quot;javascript:void(0);&quot; onMouseover=&quot;ShowPop('term1');&quot; onMouseout=&quot;HidePop('term1');&quot;>Show me the answer</a></span>

UPDATE2: 这是屏幕的输出

This is the answer  Show me the answer

在哪里...

告诉我答案是指向的超链接http://localhost:1391/"javascript:void(0);"

4

1 回答 1

1

href您在属性末尾和属性之间缺少空格onMouseOver

更新:(以下评论)

将鼠标悬停在链接上时,某些浏览器会显示href属性指向的位置。在这种情况下,这将是“javascript:void(0);”。有些会将主机 URL 附加到此预览中,有些则不会。

更新2:(以下更新回答)

看起来框架是对您正在使用的字符串进行 HTML 编码。确保Mode将文字控件的属性设置为LiteralMode.PassThrough.

更新3:(经过一些测试)

我尝试在本地使用带引号的字符串并且没有问题。您确定在设置 text 属性之前您不是 HTML 编码,或者它没有编码吗?在设置 text 属性之前尝试 HTML 解码。

于 2010-05-26T17:17:18.763 回答