How to programmatically determine name of CKEditor instance

后端 未结 6 2042
野趣味
野趣味 2021-01-05 03:40

I\'ve added a CKEditor instance programmatically to my page in the code-behind of my ASP.NET page:

VB.NET:

itemEditor = New CkEditor
cell.Controls.Ad         


        
6条回答
  •  天命终不由人
    2021-01-05 04:04

    Well I've found a way... but I don't like it much...

    I've added a Hidden Field control to the page, after adding the editor, and put the editor's ClientId in its value:

    Dim hdn As New HiddenField
    With hdn
        .ID = "HiddenField"
        .Value = itemEditor.ClientID
    End With
    cell.Controls.Add(hdn)
    

    .. and then in the JavaScript, I can get the hidden field, and hence the editor name as follows:

    function GetCkText()
    {
        var hdn = document.getElementById("HiddenField");
        var editorName = hdn.getAttribute("value");
        var editor = CKEDITOR.instances[editorName];
        alert(editor.getData());
        return false;
    }
    

    But it's a bit inelegant, to say the least. Anyone got a better way?

提交回复
热议问题