开发者

Creating dynamic text for a literal control

开发者 https://www.devze.com 2023-01-01 07:40 出处:网络
On the ListView1_ItemDataBound of a list view event, i create the literal.text like so... <span style=&quot;position:relative;&quot;>

On the ListView1_ItemDataBound of a list view event, i create the literal.text like so...

<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>

The problem is that the text is not rendered as it should. On mousing over the literal control the url is

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

So what is going on here? What am i missing?

UPDATE1: Here is the source from the browser

 <span style=&quot;position:relative;&开发者_开发百科amp;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: And here is the output from the screen

This is the answer  Show me the answer

where...

Show me the answer is the hyperlink to http://localhost:1391/"javascript:void(0);"


You are missing a space between the end of the href attribute and the onMouseOver attribute.

Update: (following comment)

When hovering over a link, some browsers will show you where the href attribute points. In this case this would be "javascript:void(0);". Some will append the host URL to this preview, some will not.

Update 2: (following update to answer)

Looks like the framework is HTML Encoding the strings you are using. Make sure you set the Mode property of the literal control to LiteralMode.PassThrough.

Update 3: (following some testing)

I tried locally using string with quotes and had no problem. Are you sure you are not HTML encoding before setting the text property, or that it isn't coming in encoded? Try HTML decoding before setting the text property.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号