Search code examples
c#asp.netwebformsrich-text-editorfreetextbox

Problem with <br> tag using FreeTextBox in ASP.NET Webforms


I have a problem with using FreeTextBox in my ASP.NET webforms project. I have multiple textboxes from which I am passing the value to my FreeTextBox on click. Everything works well, the text appears and I can edit it, but if I missed to enter something in those multiple textboxes, I cannot enter nothing in them and my button for passing the value becomes useless.

I have one textbox for entering the First Name and another one for entering the Last Name. For example if I enter John as first name and Smith as last name and pass the value to my freetextbox, it appears as John Smith. If I missed to enter Jr and I need it to be John Jr, I am not allowed to do that after I click the pass button. I can't add new textbox, or pass the value to the editor.

I have tried to add httpRuntime requestValidationMode="2.0" in my web.config file, but it did not help. Also, I have tried to change the editor, like tinymce, chkeditor, ajax html editor extender, but it made everything worse. What am I doing wrong? Maybe you could suggest me another rich text editor. Thanks for your help.

EDIT:The problem was with adding the br tag. It can't contain < or > sign. Nothing else works for freetextbox, except for the br tag. I have tried with \n,&#13; but the whole text is in one row. Does anyone have idea what could be the problem? Thanks in advance.

 <asp:TextBox ID="fName" runat="server"></asp:TextBox>
 <asp:TextBox ID="lName" runat="server"></asp:TextBox>
 <FTB:FreeTextBox ID="FreeTextBox1" runat="server"></FTB:FreeTextBox>
 <asp:Button ID="pass" runat="server" Text="Pass" OnClick="pass_Click" />

  protected void pass_Click(object sender, EventArgs e)
    {
     string text = "The name and the surname are";
     Session["FirstName"] = fName.Text;
     string FirstName = Session["FirstName"].ToString();
     Session["LastName"] = lName.Text;
     string LastName = Session["LastName"].ToString();
     FreeTextBox1.Text = text + "<br>" + FirstName + "<br>" + LastName + "<br>";
     }
        

Solution

  • The problem is solved with adding <pages validateRequest="false"></pages> in my Web.Config file