1

I have the following code:

  Dim lStatementText As String
  Dim lStatementString As New System.Text.StringBuilder

  lStatementString.Append(RndRes.Forms.txt_request)
  lStatementString.Append(" ")
  lStatementString.Append("<b><a>")
  lStatementString.Append(Request.ID)
  lStatementString.Append("</a> - <a>")
  lStatementString.Append(Request.Description)
  lStatementString.Append("</a></b> ")
  lStatementString.Append(RndRes.Forms.txt_IsNotYetLoaded)
  lStatementString.Append(". ")
  lStatementString.Append(RndRes.Forms.txt_click)
  lStatementString.Append(" <b><a>")
  lStatementString.Append(RndRes.Forms.txt_here)
  lStatementString.Append(" </a></b> ")
  lStatementString.Append(RndRes.Forms.txt_GetFromDB)

  lStatementText = lStatementString.ToString()

  Dim lLink As New Infragistics.Win.FormattedLinkLabel.UltraFormattedLinkLabel()
  lLink.Value = lStatementText
  lLink.TreatValueAs = FormattedLinkLabel.TreatValueAs.FormattedText
  AddHandler lLink.LinkClicked, AddressOf OnLinkClicked

Where Request.ID, Request.Description and also RndRes.Forms.txt_* are all strings. I want to display the string I build up here in a Infragistics FormattedLinkLabel. The problem is that if any of the strigs from the Request class contains a HTML character, the label is not displayed properly and the HTML encoding is broken. I need to find a function that masks the HTML codes.

4
  • You appear to have forgotten to put your code in your question =) Commented Jul 30, 2010 at 11:34
  • Don't forget to add the code... Commented Jul 30, 2010 at 11:34
  • now this sucks... I'll add the content in a few minutes... sorry about that. Commented Jul 30, 2010 at 11:35
  • no need i have posted the answer Commented Jul 30, 2010 at 11:36

2 Answers 2

4

If you don't have an HttpContext object at hand, look at HttpUtility.HtmlEncode:

http://msdn.microsoft.com/en-us/library/73z22y6h.aspx

Sign up to request clarification or add additional context in comments.

Comments

2

Try Server.HtmlEncode() and Server.HtmlDecode(), http://msdn.microsoft.com/en-us/library/hwzhtkke.aspx

1 Comment

Thanks! The solution you provided is good and that's why I gave you a vote up. But the solution from tdammers was easier and more appropriate for my case and I used that one eventually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.