All posts

Telerik RadControls in Microsoft ASP.NET MVC

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]

Facebook Twitter DZone It! Digg It! StumbleUpon Technorati Del.icio.us NewsVine Reddit Blinklist Add diigo bookmark

Comments  7

  • 19 Oct

    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

    GrZeCh

  • 24 Oct

    is it possible to use asp.net with mvc framwork, and what diffrences should be applied

    jalal al haddad

  • 02 Jun

    It would sure be helpful if you updated the code for MVC 1, since many things have changed, including the ActionLink.

    CarmelFrank

  • 03 Jun

    Vlad

  • 08 Jun

    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

    CarmelFrank

  • 10 Jun

    Hi Frank,

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

    --Rosen

    Rosen

  • 10 Jun

    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

    CarmelFrank

Post a comment
  1. Formatting options
       
     
     
     
     
       
  2. Security image