2009-04-29 22 views
1

我有一個文本框,其中我必須在stringbuilder中編寫內容。 以下是我的stringbuilder。如何將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>") 

我用textbox.text = strString.ToString(),但在html標籤R還顯示。 我想寫在textbox.What代碼我要寫,以刪除html標籤,我想寫在上面給出的html格式?

回答

2

無需在文本框的標籤,你應該做的事情如下所示:也是很糟糕形成

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 
2

這應做到:

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

僅供參考。

根據Jose的建議,您可以刪除html,但這不會保留HTML表格佈局......您只需將所有內容都作爲單獨的行。就像明智一樣,如果您試圖將其從文本框中保存下來,您將無法使用HTML格式。

+0

你的HTML。 – 2009-04-29 10:09:10

相關問題