Telerik RadControls in Microsoft ASP.NET MVC

Thursday, October 02, 2008 by Vladimir Enchev | Comments 8

To continue with my previous blog post about RadGrid for ASP.NET AJAX in Microsoft ASP.NET MVC, I've made another example how to use RadControls for ASP.NET AJAX as pure client-side components in this environment. The biggest challenge here is the ScriptManager and scripts registration in general. By default the creation of client-side components is so tightly coupled with the ajax functionality (PageRequestManager) that the only way to enable this is to inherit from ScriptManager (or RadScriptManager) and build everything manually:

protected override void Render(HtmlTextWriter writer)
{
     foreach (RegisteredScript script in GetRegisteredClientScriptBlocks())
     {
         if (Page.Items[script.Key] == null)
         {
             Page.Items[script.Key] = true;

             if (script.ScriptType == RegisteredScriptType.ClientScriptInclude)
             {
                 writer.WriteLine(String.Format(@"<script type=""text/javascript"" src=""{0}""></script>", HttpUtility.HtmlEncode(script.Url)));
             }
         }
     }

    ...

}

The result: Fully functional client-side enabled RadControls for ASP.NET AJAX with skins, scripts and styles combination, etc.!

Untitled

Untitled3Untitled2  Untitled4 

Untitled5Untitled6 

Enjoy!

[Download]

8 Comments

  • GrZeCh 19 Oct 2008
    Hello! I think there is error in web.config file. There is: add assembly="System.Web.Abstractions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/ add assembly="System.Web.Routing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/ which is causing error. Changing 0.0.0.0 to 3.5.0.0 fixes problem
  • jalal al haddad 24 Oct 2008
    is it possible to use asp.net with mvc framwork, and what diffrences should be applied
  • CarmelFrank 02 Jun 2009
    It would sure be helpful if you updated the code for MVC 1, since many things have changed, including the ActionLink.
  • Vlad 03 Jun 2009
  • CarmelFrank 08 Jun 2009

    Vlad,

    Thanks for the links. I'm trying to populate a RadGrid in MVC by passing data objects gathered with Linq via JSON from a controller action. The first link to the MvcForum code uses the Telerik Open Access ORM, and the examples in the second link are for RadComboBox and RadTreeView, both of which support the WebServiceSetting tag while the RadGrid does not. The RadComboBox has the RadComboBoxData class, and the RadTreeView has the RadTreeNodeData class to support it - I find no analog for the RadGrid.

    Some sample code which demonstrates populating a RadGrid in MVC using JSON would be extremely helpful to me.

    Frank

  • Rosen 10 Jun 2009
    Hi Frank,

    You may download a small sample app which demonstrates how to populate a RadGrid using  JsonResult from here.

    --Rosen
  • CarmelFrank 10 Jun 2009

    Wow! Thanks!

    Something is which is critical to my application is the ability to create columns at runtime (i.e. dynamically change the TableView). Is there a way to do that, or does the fact that RadGrid is server-side mean that's not possible?

    I'd also like to be able to handle RadGrid events client-side, using Javascript to call the controller.

    Thanks again for your responsiveness!

    Frank

  • Doc 13 May 2010
    I have downloaded the trial version.
    I am using Visual Studio 2008 on Windows 7
    I was experimenting with the ajax controls - they disappeared.
    How do I get them back?

Add comment

  1. Formatting options
       
     
     
     
     
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)