TextBox using HTMLEditorExtender does not insert new line when pressing Enter
Asked Answered
S

2

7

I am using AjaxToolKit's HTMLEditorExtender control in my website. The markup is as follows:

<asp:TextBox ID="TextBox2" runat="server" 
        Font-Names="'lucida grande',tahoma,verdana,arial,sans-serif" Height="100%" OnTextChanged="TextBox2_TextChanged" 
        style="margin-bottom: 26px; font-size: small;" Width="90%"></asp:TextBox>

<asp:HtmlEditorExtender ID="TextBox2_HtmlEditorExtender" runat="server" 
        Enabled="True" TargetControlID="TextBox2">
    <Toolbar>
        <asp:Undo />
        <asp:Redo />
        <asp:Bold />
        <asp:Italic />
        <asp:Underline />
        <asp:StrikeThrough />
        <asp:Subscript />
        <asp:Superscript />
        <asp:InsertOrderedList />
        <asp:InsertUnorderedList />
        <asp:RemoveFormat />
        <asp:SelectAll />
        <asp:UnSelect />
        <asp:Delete />
        <asp:Cut />
        <asp:Copy />
        <asp:Paste />
        <asp:Indent />
        <asp:Outdent />
        <asp:FontNameSelector />
    </Toolbar>
</asp:HtmlEditorExtender>

Running the application, and pressing Enter while TextBox2 has focus, no new line is inserted; instead, TextBox2 loses focus.

This doesn't happen unless the HTMLEditorExtender is attached to TextBox2.

More Details

I am running the application in local IIS. The website is live but the feature is not launched on the main website yet. I am using ASP.NET WebForms and latest AjaxToolkit version. Also this problem is in every browser including Chrome, IE, Opera, Firefox.

Shortstop answered 2/3, 2013 at 10:35 Comment(6)
Does adding TextMode="Multiline" to asp:TextBox ID="TextBox2" help?Plated
no it was multiline before. I removed that property to test whether it works without applying multiline property but no difference.Shortstop
I dont know why it wouldnt work. Increase the height/width of the textbox with multiline set. Clear the cache, build the solution and see.Plated
no that didn't worked. I changed the size of the text box and also cleared the cache. But no difference.Shortstop
please anyone answer it as soon as possible...Shortstop
@ShivaPareek what's your test environment? Is the application running on your computer? Hosted server? I'm assuming you are using ASP.NET WebForms. What browser are you using? Version? AjaxControlTolkit version? Please add these details to your question.Surcingle
S
4

Finally I solved the error myself. The code which I provided was enclosed in a Panel that has a default button. So I removed the DefaultButton property and the code is working fine now. Thank you all for adding your responses.

Shortstop answered 5/3, 2013 at 16:16 Comment(0)
C
0

I believe you need to set the number of rows. Take a look at this example, as I know it works for me:

<ajax:HtmlEditorExtender ID="tbCommentHtmlExtender" runat="server"  
TargetControlID="tbEditor" DisplaySourceTab="false" EnableSanitization="false">  
  <Toolbar>                                        
   <ajax:FontNameSelector />
   <ajax:FontSizeSelector />
   <ajax:Bold />
   <ajax:Italic />
   <ajax:Underline />
   <ajax:StrikeThrough />
   <ajax:JustifyLeft />
   <ajax:JustifyCenter />
   <ajax:JustifyRight />
   <ajax:JustifyFull />
   <ajax:InsertOrderedList />
   <ajax:InsertUnorderedList />
   <ajax:CreateLink />
   <ajax:UnLink />
   <ajax:RemoveFormat />
   <ajax:BackgroundColorSelector />
   <ajax:ForeColorSelector />
  </Toolbar>
</ajax:HtmlEditorExtender>  

<asp:TextBox ID="tbEditor"  runat="server" Width="570px" Height="570px"  Rows="10" TextMode="MultiLine" ></asp:TextBox>

Also, what is

OnTextChanged="TextBox2_TextChanged"

doing? If my above suggestion doesn't work, try removing that. If that works, post the corresponding function.

Connors answered 5/3, 2013 at 11:57 Comment(3)
Ya I removed OnTextChanged="TextBox2_TextChanged" and added 20 rows to the textbox, still no effect.Shortstop
Also its working without any error on a blank aspx page which I created to test this.Shortstop
in that case, it sounds like something else is going on. maybe let us see more codeConnors

© 2022 - 2024 — McMap. All rights reserved.