不能在标签中显示新行



嗨,我有一个使用vb.net的代码。我需要在文本框中获取文本作为调用javascript函数的参数,该函数在父页面上的标签中设置文本。我用<br/>替换新线。但标签上仍然显示<br/>。谁能告诉我怎么解它。提前谢谢。

文本框中的文本:

test [  ^ $ . | ? * + ( )'
new line

文本显示在父标签中:

test [ ^ $ . | ? * + ( )'<br/>new line

这是我的代码在vb.net

Dim script as string="" 
Dim strText As String = txtNote.Text.Trim.Replace("'", "'")
strText = strText.Replace(Environment.NewLine, "<br/>")
script = "window.parent.showNote('" & Server.HtmlEncode(strText) &  "');"
ScriptManager.RegisterStartupScript(Me.Page, Me.Page.[GetType](), "EditNote", script, True)

有javascript:

function showNote(txt){
$('#lbl').html(txt);
}

我更改了代码和工作:

Dim script as string="" 
Dim strText As String = txtNote.Text.Trim.Replace("'", "'")
strText A=Server.HtmlEncode(strText)
strText = strText.Replace(Environment.NewLine, "<br/>")
script = "window.parent.showNote('" & strText &  "');"
ScriptManager.RegisterStartupScript(Me.Page, Me.Page.[GetType](), "EditNote", script, True)

最新更新