tags:

views:

307

answers:

3

hi guys, I have a textbox in which i have to write content inside stringbuilder. Following is my stringbuilder.

Dim strString As New StringBuilder()
        strString.AppendLine("<table>")
        strString.AppendLine("<tr><td>")
        strString.AppendLine("<br/><br/>")
        strString.AppendLine("<div style=""text-transform: capitalize;""><strong>Dear " & Session("PatientName") & ",")
        strString.AppendLine("</strong></div></td></tr>")
        strString.AppendLine("<br/><br/>")
        strString.AppendLine("<tr><td>")
        strString.AppendLine("Your appointment has been confirmed.")
        strString.AppendLine("<br /><br />")
        strString.AppendLine("Your appointment Time: " + Session("AppTime"))
        strString.AppendLine("<br />")
        strString.AppendLine("Your appointment Date: " + Session("AppointmentDate"))
        strString.AppendLine("</td></tr>")
        strString.AppendLine("<tr><td>")
        strString.AppendLine("<br/><br/>")
        strString.AppendLine("</table>")

I have used textbox.text=strString.ToString().But in that html tags r also displaying. I want to write above in a textbox.What code i hve to write to remove html tags and i want to write in above given html format?

+2  A: 

This should do it:

textbox.Text = Regex.Replace(strString.ToString(), _
                         "<(.|\n)*?>", string.Empty)
Jose Basilio
+1  A: 

Just FYI.

You could remove the html as per Jose's suggestion but that's not going to preserve the HTML Table layout... you'll just get everything as individual lines. Like wise, you'll have no HTML formatting if you're trying to save this back from the textbox.

Eoin Campbell
Also your HTML is very badly formed.
Dead account
+1  A: 

No need for the tags in a textbox, you should do something like the following:

Dim strString As New StringBuilder()
strString.AppendLine()
strString.AppendLine("Dear " & System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(Session("PatientName")) & ",")
strString.AppendLine()
strString.AppendLine("Your appointment has been confirmed.")
strString.AppendLine()
strString.AppendLine("Your appointment Time: " + Session("AppTime"))
strString.AppendLine("Your appointment Date: " + Session("AppointmentDate"))
textbox.text = strString.ToString
Patrick McDonald