简体   繁体   中英

Get all lines from multiline textbox

I have multiline textbox with HtmlExtender control from AjaxControlToolkit in my Web Forms application. And I have troubles with getting all of the text from textbox including linebreaks. I have this code:

Dim text As String = txtText.Text.Replace(Environment.NewLine, "<br/>")

But I get only first line of text everytime. So I set a breakpoint and discovered that value (text) of textbox is always the first line.

在此处输入图片说明在此处输入图片说明

What can I do with this, where is a problem? Is possible that there is any problem with ajax extender and textbox?

Thanks for answer.

string[] allLines = txtText.Text.Split('\n');

I found the solution. I set EnableSanitization="False" and it works fine.

Code:

<asp:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="txtText" EnableSanitization="False">
  <toolbar>
   ...
  </toolbar>
</asp:HtmlEditorExtender>

<asp:TextBox ID="txtText" runat="server" TextMode=MultiLine />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM