Search code examples
c#asp.netvb.netajaxcontroltoolkit

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.

enter image description here enter image description here

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.


Solution

  • 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 />