locked
HTMLEditorExtender not working with Justify Center RRS feed

  • Question

  • User-153404742 posted

    Not sure why but when applied the justification options for center or other alignment, it shows fine but any postback event sets the text back to the left.  The Control is inside the UpdatePanel.  Any help is appreciated.

    <asp:HtmlEditorExtender id="editorNote" TargetControlID="tbEditor" runat="server">

    </asp:HtmlEditorExtender>

    Tuesday, August 11, 2020 10:46 PM

All replies

  • User-1330468790 posted

    Hi inkaln,

     

    Could you please share your codes which could be used to reproduce the problem?

     

    The problem might be caused by the way you trigger the post back event. However, I constructed a simple demo which works normally. It would be helpful to target the problem easier if you could provide me with the part of problematic codes.

     

    You could refer to below codes which keeps the justification after the postback.

    HTML:

    <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <div>
                <asp:UpdatePanel ID="updatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:TextBox runat="server"
                            ID="txtBox1"
                            TextMode="MultiLine"
                            Columns="50"
                            Rows="10"
                            Text="Hello <b>world!</b>" />
    
                        <ajaxToolkit:HtmlEditorExtender
                            ID="htmlEditorExtender1"
                            TargetControlID="txtBox1"
                            runat="server">
                        </ajaxToolkit:HtmlEditorExtender>
                        
                        
                    </ContentTemplate>
                </asp:UpdatePanel>
               
            </div>
            <br />
             <asp:Button ID="submit" Text="Do Post Back" runat="server" OnClick="submit_Click" />
            <div style="width:200px;height:200px;border:solid 1px">
                <asp:Label ID="display" runat="server"></asp:Label>
            </div>
            
        </form>

    Code behind:

     protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void submit_Click(object sender, EventArgs e)
            {
                display.Text = txtBox1.Text;
            }

    Demo:

     

    Best regards,

    Sean

    Wednesday, August 12, 2020 2:23 AM
  • User-153404742 posted

    I have the related code as follows:

    <div class="box-body no-padding table-responsive">

    <div class="col-xs-12" style="min-height:410px;">

    Title: <asp:TextBox ID="tbTitle" runat="server" Width="400px"></asp:TextBox><br /><br />

    <asp:TextBox ID="tbEditor" CssClass="prog-html-editor" runat="server" TextMode="MultiLine" Height="400" Width="800"></asp:TextBox>
    <asp:HtmlEditorExtender id="editorNote" TargetControlID="tbEditor" runat="server">

    </asp:HtmlEditorExtender>
    </p>
    </div>
    <div class="col-xs-12 note-save-btn-wrapper">
    <p>Author: <asp:Label ID="lblAuthor" runat="server"></asp:Label> Time: <asp:Label ID="lblTimeCreated" runat="server"></asp:Label></p>
    <p><span class="strong">Active:</span> <span class="active-check"><asp:CheckBox ID="cbActive" runat="server" /></span>Mark the checkbox to make this content active on the portal.</p>

    <asp:Button ID="btnSave" runat="server" Text="Save and Close" OnClick="btnSave_Click" />
    <br />
    <div id="divArticleStatus" runat="server" visible="False" class="mar-top login-error alert-warning text-center">
    <asp:Literal ID="lblStatus" runat="server" />
    </div>
    </div>

    </div>

    The above is inside the <updatePanel> <contentTemplate> control....even the click on the checkbox causes the centered text to go back left....not sure.

    Wednesday, August 12, 2020 3:26 PM
  • User-1330468790 posted

    Hi inkaln,

     

    Since the text box control has a view state to keep the value and state, the value will not be lost when you trigger a post back. 

    Could you please share the related codes for the TextBox control "tbEditor" from code behind? 

    The only reason I can guess is that you might assign the text box with a string which does not contain the format after the post back.

     

    You could refer to below codes to see if it is the case.

    aspx:

    <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <div>
                <asp:UpdatePanel ID="updatePanel1" runat="server">
                    <ContentTemplate>
    
                        <div class="box-body no-padding table-responsive">
    
                            <div class="col-xs-12" style="min-height: 410px;">
                                Title:
                                <asp:TextBox ID="tbTitle" runat="server" Width="400px"></asp:TextBox><br />
                                <br />
    
                                <asp:TextBox ID="tbEditor" CssClass="prog-html-editor" runat="server" TextMode="MultiLine" Height="400" Width="800"></asp:TextBox>
                                <ajaxToolkit:HtmlEditorExtender ID="editorNote" TargetControlID="tbEditor" runat="server">
                                </ajaxToolkit:HtmlEditorExtender>
                                </p>
                            </div>
                            <div class="col-xs-12 note-save-btn-wrapper">
                                <p>
                                    Author:
                                    <asp:Label ID="lblAuthor" runat="server"></asp:Label>
                                    Time:
                                    <asp:Label ID="lblTimeCreated" runat="server"></asp:Label>
                                </p>
                                <p>
                                    <span class="strong">Active:</span> <span class="active-check">
                                        <asp:CheckBox ID="cbActive" runat="server" /></span>Mark the checkbox to make this content active on the portal.
                                </p>
    
                                <asp:Button ID="btnSave" runat="server" Text="Save and Close" OnClick="btnSave_Click" />
                                <br />
                                <div id="divArticleStatus" runat="server" visible="False" class="mar-top login-error alert-warning text-center">
                                    <asp:Literal ID="lblStatus" runat="server" />
                                </div>
                            </div>
    
                        </div>
                        <div style="width: 200px; height: 200px; border: solid 1px">
                            <asp:Label ID="display" runat="server"></asp:Label>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </form>

    Code behind:

    protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    tbEditor.Text = "Hello World";
                }
            }
    
            protected void btnSave_Click(object sender, EventArgs e)
            {
                // Actually the value of tbEditor.Text is not a simple string "Hello World"
                display.Text = HttpUtility.HtmlEncode(tbEditor.Text);
                
                // Assign the tbEditor.Text with a simple string "Hello World", the format will be cleared
                tbEditor.Text = "Hello World";
    
            }

    Demo:

     

    Hope this can help you.

    Best regards,

    Sean

    Thursday, August 13, 2020 9:03 AM