问题
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