I have visited the Telerik's website and viewed their demos etc... But I am having problems trying to load content (html) in the RadEditor.
I have a Button_Click event where I get my html string and then set it to the RadEditor. The RadEditor is inside a RadWindow and only becomes visible when the button is clicked.
protected void btnSubmitHtml_Click(object sender, EventArgs e) { RadEditor1.Content = "<p>hello there</p>"; RadWindow1.Visible = true; }This doesn't show the html inside the RadEditor for some odd reason. I suspect it is the page life cycle that is involved with this problem.
Are there any suggestions to solve this?
3 Answers
I have encountered this problem multiple times and never found a "Proper" resolution.
However, a great work around is to simply set the content from the clientside via injected script. The end result is the same, and if you can tolerate the 10 millisecond delay, worthy of consideration.
EDIT after comment requested reference
Basically all you need to get an instance of the editor using ASP.NET WebForms $find function. That takes the html ID of the root of the rendered object and returns the client side viewModel if one exists.
The $(setEditorInitialContent) call at the end assumes that jQuery is present and delays the execution of the function till page load.
<telerik:radeditor runat="server"> <Content> Here is sample content! </Content>
</telerik:radeditor>
<script type="text/javascript"> function setEditorInitialContent() { var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object editor.set_html("HEY THIS IS SOME CONTENT INTO YOUR EDITOR!!!!"); } $(setEditorInitialContent);
</script> 1 Take a look here to see how to get a RadEditor to work in a RadWindow: .
Said shortly, here is what you need to have in the OnClientShow event of the RadWindow:
function OnClientShow()
{ $find("<%=RadEditor1.ClientID %>").onParentNodeChanged();
} To edit Html code only you can add -
EnableTextareaMode="true"Add this property to the RadEditor.
I suspect that the way the control tries to interpret the html might be one of the problems. The other thing that may be causing this problem is the page life cycle.