views:

576

answers:

2

I am using the Telerik RadEditor (Q1 2009 SP1) in our ASP.NET MVC (RTM) project. The editor works great when rendered as a hardcoded object on the page with a static id. But when extending with an HtmlHelper to do dynamic creation by passing in an Id it seems to render the html as all lowercase for the tag. Does the HtmlHelper object mess with this innately by chance? The attributes look upper and lowercase respectively but this seems strange. Here is my code....thanks in advance!

               <% if (placeholder.Type.ToLower() == "richtext") { %>
                    <%= Html.RadEditor("placeholder_" + placeholder.Name) %>
                <% } else { %>
                    <%= Html.TextBox("placeholder_" + placeholder.Name, null, new { @class = placeholder.Type }) %>
                <% } %>

The helper looks like this....

   public static string RadEditor(this HtmlHelper html, string Id)
    {
        var sb = new StringBuilder();

        sb.Append("<telerik:RadEditor ID='" + Id + "' Runat='server' DialogHandlerUrl='~/Telerik.Web.UI.DialogHandler.axd'>");
        sb.Append("<Content>");
        sb.Append("</Content>");
        sb.Append("</telerik:RadEditor>");

        return sb.ToString();
    }
+1  A: 

The problem is the tag is a server side control. When you place it hardcoded in your page, the server side tag gets translated to html. When you're using the htmlhelper, you're outputting the html and it doesn't get processed as a server side tag.

If you want to do something dynamic, you should use a UserControl (.ascx file) and then use the Html.RenderPartial method.

ajma
+2  A: 

For the time being you cannot render RadEditor without having a valid Page object with a ScriptManager. We (Telerik that is) plan to add support for "standalone" rendering in the near future. Should be announced in a blog post so stay tuned.

korchev
thanks. I did achieve a workaround using an iFrame that I'll post here and on telerik's site for others to use. I think htmlHelpers will help all to use those awesome controls in MVC.
dodegaard