How to get instance of editor wrapped in UserControl?

Last post 12-18-2008, 2:15 AM by Anonymous. 4 replies.
Sort Posts: Previous Next
  •  12-17-2008, 4:06 AM 47011

    How to get instance of editor wrapped in UserControl?

    Hi Adam,

    I have a problem. I have created a usercontrol (myusercontrol) and in that I have placed cuteEditor control. On my application I 'm using this user control which exposes some of required properties and methods of cuteeditor.

    On some pages I have a requirement to get the HTML content of myusercontrol.
    WhatI'm trying is to get the instance of myusercontrol and then try to call the getHtml method. Is that correct?
    How to get instance of editor wrapped in UserControl?
     
    Somehow I tried toget the instance in javascript by using following
     
    var contentData = document.getElementById('ctl00$cplxyz$myusercontrol$Editor2').value;

    but this will give me junk data also. I tried .innerHTML and .innerText also but same result.
    means If I entered "abc" in editor, then the above returns something like '#dbc" etc or something like that.

    Please suggest some solution for this.

    Thanks




    Thanks
  •  12-17-2008, 12:13 PM 47035 in reply to 47011

    Re: How to get instance of editor wrapped in UserControl?

    Please use .getHTML method to get the content from the editor.
     
    This method is used for retrieving the content of CuteEditor as HTML.

    Example:

    // get the cute editor instance
    var editor1 = document.getElementById('<% = Editor1.ClientID%>');

    // retrieving the content of Cute Editor as HTML
    var content = editor1.getHTML();
    alert(content );

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  12-17-2008, 12:50 PM 47048 in reply to 47035

    Re: How to get instance of editor wrapped in UserControl?

    Hi Adam,
     
    I tried this but as I mentioned earlier that I have created a usercontrol that is myUserControl and I placed cuteEditor control in it. Now when I try to to get the instance of editor I have to use name of control and in my case the name is something like
     ctl00$myUserControl$xyz$Editor2
     
    First case:
     
    if I pass this to in following code
    var editor1 = document.getElementById('<% = ctl00$myUserControl$xyz$Editor2.ClientID%>');
     
    Then it is giving the editor1 =Null or undefined.  
     
    Second case:
    Next if I try to get the instance by calling following code
    var editor1 = document.getElementById('ctl00$myUserControl$xyz$Editor2');
     
    Then I get the object instance. but with this I could not Get the method editor1.getHTML. Only I can get is methods like
    editor1.innerHTML or editor1.value. But this gives me junk characters along with the actual content.
     
    So either I should get some way to execute the case 1 code correctly  so that I can get the GetHTML method or some way for case 2 to get the proper content.
     
    Thanks
     
     
     
     

     

  •  12-17-2008, 1:20 PM 47050 in reply to 47048

    Re: How to get instance of editor wrapped in UserControl?

    You can use the browser's "View Source..." to get the editor ID:
     
    <table cellspacing="0" cellpadding="0" _IsCuteEditor="True" id="CE_Editor1_ID"

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  12-18-2008, 2:15 AM 47068 in reply to 47050

    Re: How to get instance of editor wrapped in UserControl?

    Hi Adam,
    Thanks ..it worked... But in firefox mozilla it is not working for a specific case.
     
    I have a page where I'm using 2 editor's. Basedon some logic it is required to show or hide the editor.so if one editor is hidden (for this I'm using "display:none"),then the above is not working inFirefox when I use
     
    var contentData = document.getElementById('CE_ctl00_abc_myUserControl_Editor2_ID').GetHTML(); (Visible on page)
    var contentData= document.getElementById('CE_ctl00_xyz_myUserControl_Editor2_ID').GetHTML(); (display:none:- not visible on page))
    Giving Error: document.getElementById("CE_ctl00_xyz_myUserControl_Editor2_ID").GetHTML is not a function
     
    Pls suggest!
     
    Thanks
View as RSS news feed in XML