The Q3 2008 release is now out and I am glad to inform you that RadScriptManager provides support for ASP.NET MVC view and master pages. What this means is that RadControls for ASP.NET Ajax can be used in ASP.NET MVC. We have tested with the ASP.NET MVC Beta 1 release.
1. Add an instance of RadScriptManager to your view page (or master page). Make sure the required HTTP handlers are properly registered (can be done from the smart tag in design time).
2. Add a control to your view page or master page. The following controls require further configuration in order to properly work in ASP.NET MVC:
<add path="Telerik.Web.UI.DialogHandler.aspx" ... />After:
<add path="Telerik.Web.UI.DialogHandler.axd" ... />
<telerik:RadEditor runat="server" ID="RadEditor1" DialogHandlerUrl="~/Telerik.Web.UI.DialogHandler.axd" />
<add path="Telerik.RadUploadProgressHandler.ashx" ... />After:
<add path="Telerik.RadUploadProgressHandler.axd" ... />
<telerik:RadProgressManager runat="server" ID="RadProgressManager1" AjaxUrl="~/Telerik.RadUploadProgressHandler.axd"/>
<add path="Telerik.Web.UI.DialogHandler.aspx" ... />After:
<add path="Telerik.Web.UI.DialogHandler.axd" ... />
This approach is useful when you need a navigation control (RadTreeView, RadTabStrip, RadPanelBar, RadMenu, RadToolBar) to link to actions.
<% RadTreeView1.DataBind() %>
<telerik:RadTreeView runat="server" ID="RadTreeView1">
<Nodes>
<telerik:RadTreeNode NavigateUrl='<%# Url.Action("Index")%>' Text="Index" />
<telerik:RadTreeNode NavigateUrl='<%# Url.Action("Home")%>' Text="Home" />
</Nodes>
</telerik:RadTreeView>
<%
RadGrid1.DataSource = ViewData["MyBusinessObjectCollection"];
RadGrid1.DataBind();
%>
<telerik:RadGrid runat="server" ID="RadGrid1" />
For a more advanced example check this blog post. You can also go and check the live demo.
<% using (Html.BeginForm("Upload", "Home")){%>Controller:
<telerik:RadUpload runat="server" ID="RadUpload1" ></telerik:RadUpload>
<telerik:RadProgressManager runat="server" ID="RadProgressManager1" AjaxUrl="~/Telerik.RadUploadProgressHandler.axd"/>
<telerik:RadProgressArea runat="server" ID="RadProgressArea1"/>
<input type="submit" value="Upload" />
<%} %>
public ActionResult Upload()
{
if (Request.Files.Count > 0)
{
Request.Files[0].SaveAs("path_to_file");
}
return View("Index");
}
By default ASP.NET view pages don’t have server form tag (<form runat=”server”>) which is required for ViewState and postbacks support. Partial rendering is also not supported by ASP.NET MVC and as a result RadAjaxManager and RadAjax panel are not working.
RadScheduler relies on postbacks (or ajax requests) in order to insert, update, delete appointments. Support for ASP.NET MVC will be implemented in the upcoming Q1 2009 release.
All those features rely on postbacks by default and as such are not supported in ASP.NET MVC. This blog post describes how to work around this problem.
Alternatively you can use RadStyleSheetManager in the user control used in PartialView.
The HTML of the controls is successfully updated however JavaScript is not executed by the built-in ASP.NET MVC Ajax implementation. We would provide a workaround in the future.
This stems from the fact that RadControls for ASP.NET Ajax depend on the ASP.NET Page and control lifecycle.
A full-blown ASP.NET MVC application built on top of RadControls for ASP.NET Ajax and Telerik OpenAccess is already in the works. I will blog when it is ready.
Iana Tsolova is Product Manager at Telerik’s DevTools division. She joined the company back in the beginning of 2008 as a Support Officer and has since occupied various positions at Telerik, including Senior Support Officer, Team Lead at one of the ASP.NET AJAX teams and Technical Support Director. Iana’s main interests are web development, reading articles related to geography, wild nature and latest renewable energy technologies.