5
  1. Will using MVC enabled Telerik controls with ASP.NET MVC violate the MVC model?

  2. And if not, what kind of performance hit (versus features and development speed) will there be with using Telerik controls over manually coding the HTML?

2
  • Not a direct answer, but the link you provide refers to AJAX controls, which run in the client. They aren't "normal" server-side controls, so there shouldn't be a problem. Postback is specifically mentioned as unsupported.
    – MichaelGG
    Feb 4, 2009 at 4:57
  • Yes, thanks and I realize this. So does this mean that it would not violate and is basically just a verbose Html Helper class? Is there any more of a performance hit than using a JQuery DatePicker, etc?
    – RichC
    Feb 4, 2009 at 5:46

5 Answers 5

12

Since I am the person who built that demo I think I can share my opinion as well. This sample application does not violate the MVC principles according to me. RadControls do not rely on ViewState or postbacks in MVC applications (you can check the generated output to see for yourself - no __doPostBack or __VIEWSTATE). Indeed you need to write some code to bind the grid or populate the menu - but still the code is in the View (ASPX) and is entirely related with the presentation (again this is just my opinion so I might be wrong).

I should also mention that there are some limitations indeed - some of the built-in features (that rely on postback) do not work in MVC. However will work on resolving them. Feel free to open a support ticket or forum thread should you have any particular questions with regards to RadControls and ASP.NET MVC.

1
  • thanks! Done: "Thank you for submitting your inquiry to the Telerik Support. Your ticket ID is : 189098 For reference, please use this number when communicating with the Telerik support about this inquiry."
    – RichC
    Feb 5, 2009 at 0:08
3

To your second question, regarding performance hit vs. manual coding, I think it depends on the control you're using. For example, if you use any of the Telerik navigation controls in MVC- such as Menu, TabStrip, or PanelBar- you'll save yourself a TON of manual coding (since a menu/tabstrip/etc. requires a lot of client-side code to provide the interactive features (like drop down options) and a lot of complex CSS). So, the RadControls in MVC will help restore the -productivity- you're used to when building rich ASPNET apps.

For more complex controls, like the Grid, which depend a lot on postbacks, you're mainly benefitting from the provided styling. To fit the MVC model, controls like the Grid require quite a bit of "custom" coding to "convert" postback events to URL actions, so you may not save a lot of code vs. a MVC grid template. You -will- save a lot of time on styling, though, and the performance difference should be negligble.

Hope that helps.

-Todd

0

I'm pretty sure that these rely on the PostBack model in WebForms and wouldn't be compatible with MVC views. You could probably find a way for them to work, but it wouldn't be in keeping with the MVC principles. You can mix/match WebForms with MVC Views in the same web site if needed, but I wouldn't recommend it.

What you will lose by using the Telerik controls are most of the benefits of MVC: clear separation of concerns, enhanced testability, leaner HTML, a cleaner architecture. It wouldn't surprise me to find that eventually Telerik comes out with controls for MVC. For now, I'd look at either pure Javascript implementations for client-side or hand-coded ViewUserControls if you need to reuse some common components.

4
  • So yes you can get them to work, but they're really broken, if you want them to actually work (i.e., more than just do layout) you'll have to use WebForms which breaks MVC, and they'll come out with some MVC controls in the future. Isn't that what I said?
    – tvanfosson
    Feb 4, 2009 at 12:18
  • Well, you basically just told me that postback and viewstate wouldn't work (which I already knew so I clarified my post question). My question point is do the Telerik controls (in their MVC-focused/"broken"-state) violate MVC and if not, what's the performance hit vs verbose HTMLHelpers or JQuery?
    – RichC
    Feb 4, 2009 at 15:25
  • If you are just using the control for layout and client-side functionality, I don't see how this would break MVC. The thing that would be breaking is if you needed to do set up in the codebehind for the control to work. If you're not doing this, you should be ok.
    – tvanfosson
    Feb 4, 2009 at 15:56
0

Personally, I wouldn't use the current telerik controls with MVC. I think they work in some situations (http://telerikwatch.com/2009/01/telerik-mvc-demo-app-now-available.html), but I think they are quite viewstate / postback centric. Knowing telerik, they will come out with a MVC compatible version, but looks like they have a lot of work in front of them...

0

I realize this is an old question, but Telerik's ASP.NET MVC controls are simply controls, like datepickers, grids, panelbars, tabstrips. These are not in rival to the MVC framework. They work in conjunction with it. Your question tells me you do not, or at least did not, understand what MVC really is.

For the benefit of others that may be confused, as well, MVC stands for Model-View-Controller. There's a Model, that represents objects you are using for storage or retrieval of values, a View, that displays those object values and can be used to set them through use of controls, such as Telerik's datepickers, grids, and such, and the Controller, that houses the functions that render the views and interacts with the model elements. The controls you use for updating the model must be able to interact with that model to be MVC-compliant. If they did not, they could not be advertised as MVC controls, in the first place, so yes, their controls work with, and do not "violate", the MVC framework.

Here is one such use of a datepicker control, in conjunction with a model:

VIEW:

@model MyViewModel

<%= Html.Kendo().DateTimePickerFor(model => model.ExpirationDate)
    .Name("datetimepicker")
    .Value(model.ExpirationDate)        
%>

VIEWMODEL: (or Model)

public MyViewModel() {
    public DateTime ExpirationDate { get; set; }
}

CONTROLLER:

public ActionResult Index(int id)
{
    var data = dataContext.SomeTable.Where(e => e.ID == id).FirstOrDefault();
    // return View(data); // this would allow you to use @model SomeTable 
    // in your view, and not require a ViewModel, but returns the whole 
    // record for the given ID

    // ViewModels allow you flexibility in what you return
    MyViewModel mvm = new MyViewModel();
    mvm.ExpirationDate = data.ExpirationDate;
    return View(mvm);
}

For coding them using Telerik's demos, it is a lot of copy/paste and various small edits for your specific model and data you are entering (as shown above). There is also far less code because of the controls have most everything built-in, so of course production time is cut way down, things like filtering, paging, sorting in grids is already there - you turn it on just by adding say, Filterable(), for filtering. Instead of having to create, say, individual DataColumns and add them to a DataTable, then bind that to a grid, then worry about individual OnDataBound events (which you could still do, but need less of), you instantiate a grid, add your columns, set your controller functions for creating, reading, updating, and deleting items, and set any properties on the grid, and you are done:

<%: Html.Kendo().Grid<Models.ViewModels.MyViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.ExpirationDate).Format("MM/DD/YYYY");
    })
    .HtmlAttributes(new { style = "height: 380px;" })
    .Scrollable()
    .Sortable()
    .Filterable()
    .Pageable(pageable => pageable
        .Refresh(true)
        .PageSizes(true)
        .ButtonCount(5))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Customers_Read", "Grid"))
        .Create(create => create.Action("Customers_Create", "Grid"))
        .Update(update=> update.Action("Customers_Update", "Grid"))
        .Delete(delete => create.Action("Customers_Delete", "Grid"))
    )
 %>

The "read" is as simple as taking those first 2 lines in the public ActionResult Index() above and putting them into a public Customers_Read([DataSourceRequest] DataSourceRequest request) {} function that returns data as .ToDataSourceResult(). Updating is similar to the last 3 lines in that function, since you instantiate the model, copy the values from the model that is passed in from the grid, then do something like dataContext.SaveChanges() to save. Once saved, the grid automatically does another read, so it will see the latest values. No need for anything else to run on postback to rebind the data, so no more code to write.

Just look at the code examples here to give a better idea: http://demos.telerik.com/aspnet-mvc/

1
  • 1
    Yeah, I posted this quite some time ago when they first released their MVC controls. If I remember correctly, they were a little different back then. I use MVC and the UI for ASPNET MVC exclusively now. They've come a long way.
    – RichC
    Mar 12, 2015 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.