This is a migrated thread and some comments may be shown as answers.

set_mode with AutoResizeHeight bug(generate some internal js errors on IE)

7 Answers 161 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 07 Apr 2010, 05:02 AM
Attached image is the error generated when call set_mode(2) with AutoResizeHeight enabled.(I spend few hours to figure out this reason.)

In my application, I use tabstrip to switch editor mode , but when I enabled AutoResizeHeight and call ShowText method in IE, I always encounter some internal errors (no error in Firefox).

    function OnClientTabSelected(tabstrip, args) { 
        var multiPage = $find("<%=mp.ClientID %>"); 
        var tab = args.get_tab(); 
        var editor = getEditor(); // defined in ascx control 
 
        switch (tab.get_index()) { 
            case 0: 
                showHTML(tab, multiPage, editor); 
                break
            case 1: 
                showText(tab, multiPage, editor); 
                break
            case 2: 
                showSource(tab, multiPage, editor); 
                break
        } 
    } 
    function showHTML(tab, multiPage, editor) { 
        editor.set_mode(1); 
        showEditorToolbar(true); 
        if (multiPage.get_selectedIndex() != 0) 
            multiPage.set_selectedIndex(0); 
    } 
 
    function showText(tab, multiPage, editor) { 
        editor.set_mode(2); 
        //OnClientModeChange(editor); 
        showEditorToolbar(true); 
        if (multiPage.get_selectedIndex() != 0) 
            multiPage.set_selectedIndex(1); 
        //multiPage.set_selectedIndex(tab.get_index()); 
    } 

7 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 07 Apr 2010, 01:24 PM
Hi Vincent,

I am not aware of this error and in order to help you I will need a sample working project that demonstrates this error. Could you please open a support ticket and send a sample working project which I can run, reproduce the error and debug it?

Best regards,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Vincent
Top achievements
Rank 1
answered on 07 Apr 2010, 10:36 PM
Hi Rumen

It's pretty easy to reproduce this error. I just make sample of the aspx page. You can paste it run it. BTW: In the below sample, I turn AutoResizeHeight true, so it generates the error. but if you turn it off, the error will disappear. (On the top of the page, Click "Text Editor" to see the error) I also attach another error details.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="edWithRadTab.aspx.cs" Inherits="edWithRadTab" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" /> 
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
        <Scripts> 
            <%--Needed for JavaScript IntelliSense in VS2010--%> 
            <%--For VS2008 replace RadScriptManager with ScriptManager--%> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> 
        </Scripts> 
    </telerik:RadScriptManager> 
    <telerik:RadScriptBlock runat="server"
    <script type="text/javascript"
        //Put your Java Script code here. 
 
        function OnClientTabSelected(tabstrip, args) { 
            var multiPage = $find("<%=mp.ClientID %>"); 
            var tab = args.get_tab(); 
            var editor = getEditor(); // defined in ascx control 
             
            switch (tab.get_index()) { 
                case 0: 
                    showHTML(tab, multiPage, editor); 
                    break; 
                case 1: 
                    showText(tab, multiPage, editor); 
                    break; 
                case 2: 
                    showSource(tab, multiPage, editor); 
                    break; 
            } 
        } 
        function showHTML(tab, multiPage, editor) { 
            editor.set_mode(1); 
            showEditorToolbar(true); 
            if (multiPage.get_selectedIndex() != 0) 
                multiPage.set_selectedIndex(0); 
        } 
 
        function showText(tab, multiPage, editor) { 
            editor.set_mode(2); 
            //OnClientModeChange(editor); 
            showEditorToolbar(true); 
            if (multiPage.get_selectedIndex() != 0) 
                multiPage.set_selectedIndex(1); 
            //multiPage.set_selectedIndex(tab.get_index()); 
        } 
 
        function showSource(tab, multiPage, editor) { 
            editor.set_mode(2); 
            showEditorToolbar(true); 
            if (multiPage.get_selectedIndex() != 0) 
                multiPage.set_selectedIndex(0); 
 
            //var oTool = getEditor().getToolByName("MergeFields"); //get a reference to the custom tool 
            //oTool.setState(0); 
 
            //oTool = getEditor().getToolByName("Cut"); 
            //oTool.setState(0); 
 
        } 
        function showEditorToolbar(show) { 
            $("#ed_tools").css("display", (show) ? "" : "none"); 
            $("#ed_tools2").css("display", (show) ? "" : "none"); 
        } 
 
        function getEditor() { 
            return $find("<%=ed.ClientID%>"); 
        } 
    </script> 
    </telerik:RadScriptBlock> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="Panel1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="Panel1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <div> 
    <div id="pTabs" class="tabs"
        <telerik:RadTabStrip ID="RadTabStrip1" runat="server" EnableEmbeddedSkins="False" 
            Skin="SmartmailRight" Align="Right" MultiPageID="mp" SelectedIndex="0" Width="921px" 
            OnClientTabSelected="OnClientTabSelected"
            <Tabs> 
                <telerik:RadTab Text="HTML EDITOR" Width="110px" PageViewID="v1"
                </telerik:RadTab> 
                <telerik:RadTab Text="TEXT EDITOR" Width="110px" PageViewID="v2"
                </telerik:RadTab> 
                <telerik:RadTab Text="CODE EDITOR" Width="110px" PageViewID="v3"
                </telerik:RadTab> 
            </Tabs> 
        </telerik:RadTabStrip> 
    </div> 
 
        <asp:Panel ID="Panel1" runat="server"
<telerik:RadMultiPage ID="mp" runat="server" SelectedIndex="0" Width="900px"
            <telerik:RadPageView ID="v1" runat="server"
                <div id="cp_editor_wrap"
                    <table cellpadding="0" cellspacing="0" border="0" style="width: 95%; height: 100%;"
                        <tr> 
                            <td style="width: 100%; height: 560px; padding-bottom: 5px;" valign="top"
                                <telerik:RadEditor runat="server" ID="ed"   
                                     
                    
                                    EnableResize="false" 
                                    
                                    AutoResizeHeight="true" 
                                   
                                    > 
                                </telerik:RadEditor> 
                            </td> 
                        </tr> 
                    </table> 
                </div> 
            </telerik:RadPageView> 
            <telerik:RadPageView ID="v2" runat="server"
                <table cellpadding="0" cellspacing="0" border="0" style="width: 95%; height: 100%;"
                    <tr> 
                        <td style="width: 100%; height: 560px; padding:0 0 5px 10px;" valign="top"
                            <asp:TextBox runat="server" ID="txtPlainText" TextMode="MultiLine" CssClass="plainTextBox" 
                                Height="500px" Width="900px"></asp:TextBox> 
                        </td> 
                    </tr> 
                </table> 
            </telerik:RadPageView> 
            <telerik:RadPageView ID="v3" runat="server"
            </telerik:RadPageView> 
        </telerik:RadMultiPage> 
 
             
        </asp:Panel> 
    </div> 
    </form> 
</body> 
</html> 
 

0
Vincent
Top achievements
Rank 1
answered on 07 Apr 2010, 10:40 PM
Opps, I forget to attach the another error screenshot.
0
Vincent
Top achievements
Rank 1
answered on 08 Apr 2010, 10:36 PM
Hi

Can someone respond this question?
0
Rumen
Telerik team
answered on 09 Apr 2010, 02:00 PM
Hi Vincent,

The problem is due to that the editor is invisible in TEXT EDITOR mode, but you fire its set_mode(2) method. Therefore the AutoResizeHeight method could not count the editor size and throws this error.

To fix the problem you should remove the set_mode() method from the showText function or display the editor:

function showText(tab, multiPage, editor) {
    //editor.set_mode(2);
     
    //OnClientModeChange(editor);
    showEditorToolbar(true);
    if (multiPage.get_selectedIndex() != 0)
        multiPage.set_selectedIndex(1);
    //multiPage.set_selectedIndex(tab.get_index());
}

Kind regards,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Vincent
Top achievements
Rank 1
answered on 12 Apr 2010, 01:38 AM
Hi Rumen

Thanks for your answer. I see the problem and your solution can overcome it, but the reason I need to set the state is because I want to disable all the toolbar. I don't want to confuse the user. without setting it, the toolbar still display as active. Are there any workaround?
0
Rumen
Telerik team
answered on 12 Apr 2010, 09:46 AM
Hi Vincent,

I was not able to see the toolbar at all when switching to "Text Editor mode" (see the screenshot) but if you want to hide the toolbar you can use the following line of JavaScript code:

$get(editor.get_id() + "Top").style.display = "none";

All the best,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Editor
Asked by
Vincent
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Vincent
Top achievements
Rank 1
Share this question
or