Dave Alperovich
Dave Alperovich

Reputation: 32500

Is using MVC WebGrid Bad Practice

A junior developer on my team just created a screen using an MVC Helper called WebGrid.

My first reaction was a classic NO! to anything that sounded like Grid / bound tech.

As he demo'd the functionality, it wasn't bad, though it did use

?sort=Title

type of syntax which bothers me generally. He also showed me many examples of posts regarding use on forums like Stack. One such warned against their use, but was categorical and gave no clarification. I would like to know if users have any positive or negative experiences with the WebGrid control.

Would you recommend for or against as "best practice"?

Upvotes: 1

Views: 641

Answers (1)

Jerad Rose
Jerad Rose

Reputation: 15513

I don't think you're going to get a definitive answer to this question, but I think it's a good question and deserves an answer (others may vote to close it, just as a heads-up). But this is my personal take, FWIW.

One of the benefits, to me, of MVC (vs. Web Forms) is that it provides almost full control over the rendered HTML. With Web Forms, .NET did its own crazy thing to get the front end bound to code behind, and this was magnified with using web controls.

Generally speaking, the same could be said about using controls like this in MVC -- they often limit the control one has over the rendered HTML.

Another argument is that they typically limit what you can do via client-side code (or how easy you can do it). This may be a side effect of not having full control over the HTML.

I would take a look at the HTML it produces -- you may quickly see enough reasons there not to use it (or, to use it).

Of course, the other argument is that third party controls often try to do too much, or do things differently than you'd like (like passing the sort through a query string, as you mentioned).

Upvotes: 3

Related Questions