RadControls for ASP.NET AJAX

RadControls Send comments on this topic.
Using RadEditor in ASP.NET MVC
See Also
Integrating RadControls in ASP.NET MVC > RadEditor and ASP.NET MVC > Using RadEditor in ASP.NET MVC

Glossary Item Box

Using RadEditor in ASP.NET MVC

1. RadEditor needs to be placed inside a form tag

2. To use RadEditor’s dialog you need to change the extension of the dialog HTTP handler (in web.config):
Before:

[web.config] Copy Code
<add path="Telerik.Web.UI.DialogHandler.aspx" ... />

After:

[web.config] Copy Code
<add path="Telerik.Web.UI.DialogHandler.axd" ... />


and set the DialogHandlerUrl property:

[ASPX] Set the DialogHandlerUrl property Copy Code
<telerik:RadEditor runat="server" ID="RadEditor1"
DialogHandlerUrl="~/Telerik.Web.UI.DialogHandler.axd"  />


Getting the content of RadEditor

To get the content of your RadEditor you need to use a helper method. Here is its implementation (the code is also available as part of the RadControlHelper class):

[C#] Helper methods Copy Code
public static string ExtractHtmlValue(HttpRequestBase request, string controlId)
{
     
return request.Form.Keys.OfType<string>()
        .Where(postedValue => postedValue.EndsWith(controlId))
        .Select(postedValue => request.Form[postedValue])
        .FirstOrDefault();
}

public static string ExtractStringValue(HttpRequestBase request, string editorId)
{
 
return Telerik.Web.UI.Editor.ContentEncoder.Decode(ExtractHtmlValue(request, editorId));
}

Here is how to use it:

[C#] Getting the contents of RadEditor Copy Code
public ActionResult Save()
{
   
string editorContents = RadControlHelper.ExtractHtmlValue(Request, “”
  
//Code to update your model using the editor content
}


Setting the content of RadEditor

To set the content of RadEditor you need to set the value of its Content property:

[ASPX] Setting the content of RadEditor Copy Code
<%
  RadEditor1.
Content = (string)ViewData["Content"];
%
>
<
form>
    
<telerik:RadEditor runat="server" ID="RadEditor1" />
</
form>

 

See Also