How to set HTMLEditorExtender HTML from client sid

2019-07-01 23:36发布

I cannot get this to work, here is code that I found in another thread but it is not working for me, I'm getting "set_content is not a function" :

$find("<%=Hee.ClientID%>").set_content("whatever");

Is this still valid? I also tried to set value of the textbox it extends, tried setting InnerHtml of both,none worked.

4条回答
够拽才男人
2楼-- · 2019-07-02 00:29

You could try this out:

var ctrl = $get("<%=Hee.ClientID%>").control;
ctrl.set_content("whatever");
查看更多
劫难
3楼-- · 2019-07-02 00:34
$find("<%= Hee.ClientID %>")._editableDiv.innerHTML = "whatever";
查看更多
走好不送
4楼-- · 2019-07-02 00:34

I was going nuts for hours looking for a way to change the content and here's what I've come up with that works quite well:

This is the TextBox and Extender:

<asp:Textbox ID="replyBody" Height="450px" Width="892px" runat="server" TextMode ="MultiLine"  />
<ajaxToolkit:HtmlEditorExtender ID="replyBody_HtmlEditorExtender" runat="server" Enabled="True" EnableSanitization="false" TargetControlID="replyBody">
</ajaxToolkit:HtmlEditorExtender> 

Now this is the javascript that changed the value:

<script type = "text/javascript" >
    function changeText(someString){
        document.getElementById('ctl00_ContentPlaceHolder1_replyBody_HtmlEditorExtender_ExtenderContentEditable').innerHTML = someString; 
    }
</script>

This works like a charm. The above element ID is actually that of a div, however changing its contents updates the replyBody.Text property

查看更多
迷人小祖宗
5楼-- · 2019-07-02 00:41

Try this:

$("#<%=Hee.ClientID%>").html("whatever");
查看更多
登录 后发表回答