views:

142

answers:

1

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;&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);"

+1  A: 

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.

Oded
Hello, the problem persists. Now the url points to http://localhost:1391/"javascript:void(0);"
Chocol8
@strakastroukas - I pasted your code into a new HTML document and opened in firefox. It displays "javascript:void(0);" as the URL, as expected.
Oded
@Oded - I also try this one in the design tab of the Visual studio and it also works. The problem probably occurs because the literal text is created dynamically in the itemdatabound event of the listview. Or at least i cannot think of anything else.
Chocol8
@strakastroukas - I am afraid there is not enough information in your question or comments to give a conclusive answer. Make sure the html renders out as you think by doing a "view source" - that may provide more clues.
Oded
@Oded - Please take a look at the update
Chocol8
@Oded - The problem persists with the PassThrough option too
Chocol8
@strakastroukas - did you try the other options?
Oded
Yeap. I tried both encode and pass through. This one truly drives me nuts
Chocol8
@strakastroukas - weird. `PassThrough` should work. Make sure you are not loading the page from browser cache.
Oded
@strakastroukas - 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.
Oded
I tried decoding and it works! Thank you so much!!!Do you mind posting this as an answer?
Chocol8
@strakastroukas - Answer updated ;)
Oded