How to set HTMLEditorExtender HTML from client side

我是研究僧i 提交于 2019-12-14 03:49:01

问题


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.


回答1:


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



回答2:


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




回答3:


Try this:

$("#<%=Hee.ClientID%>").html("whatever");



回答4:


You could try this out:

var ctrl = $get("<%=Hee.ClientID%>").control;
ctrl.set_content("whatever");


来源:https://stackoverflow.com/questions/9827279/how-to-set-htmleditorextender-html-from-client-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!