Textbox with “new line”

前端 未结 2 1084
难免孤独
难免孤独 2021-01-12 06:04

We tried several ways to make a textbox to accept the \"enter\", newline, etc.. But we are still facing the same problems. Most of the \"Third party\" controls allow the use

相关标签:
2条回答
  • 2021-01-12 06:14

    To avoid this problem and allow HTML tags in TextBox control you need to change ValidateRequest of Page directive to false. You can do it like in code bellow:

    use ValidateRequest="false"

    0 讨论(0)
  • 2021-01-12 06:20

    Set the mode to TextBoxMode.MultiLine

    Either in the code-behind,

    myTextBox.TextMode = TextBoxMode.MultiLine
    

    or in the markup

    <asp:TextBox TextMode="MultiLine"
    

    When the user enters text in the TextBox, it will come back to you with new lines as \r\n. If you'd like to display it properly to the user, you could use

    myTextBox.Text.Replace(Environment.NewLine, "<br />")
    
    0 讨论(0)
提交回复
热议问题