Stringbuilder problem creating dynamic links

Posted by wali on Stack Overflow See other posts from Stack Overflow or by wali
Published on 2010-01-26T05:17:06Z Indexed on 2010/05/09 5:38 UTC
Read the original article Hit count: 279

Filed under:
|

Hi all,

I'm having an issue creating a link like "<a href="javascript:window.open('www.microsoft.com');">Visit Microsoft</a> using stringbuilder. I am adding html to a panel dynamically and I am trying to create a popup link.

The problem is that for some reason the link gets "mixed up". For example:

Dim s As String
sb.Append("<A HREF='javascript:void(0)' onclick='window.open(")
sb.Append("'")
sb.Append("Match.aspx?MatchID=")
sb.Append(mt.MatchID)
sb.Append("&batchid=")
sb.Append(mb.batchID)
sb.Append("')>")
sb.Append("Match</A>")

gives an output of :

<a match.aspx?matchid="28840&amp;batchid=26596')" onclick="window.open(" href="javascript:void(0)">Match</a>

I have no clue what I'm doing wrong, it even does this kind of crap for a regular string!

Please help!

© Stack Overflow or respective owner

Related posts about stringbuilder

Related posts about ASP.NET