Pergunta

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.

Foi útil?

Solução 2

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

Outras dicas

string[] allLines = txtText.Text.Split('\n');
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top