Is there a new model or best-practise for creating complex controls in asp.net MVC?
Do you use code-behind or inline to mirror your view pages?
Is there a new model or best-practise for creating complex controls in asp.net MVC?
Do you use code-behind or inline to mirror your view pages?
My model is this:
I tend to use Partial Views when there is a view element that I ll need to use more than once. Or if I need to display multiple complex object in a view.
I use RenderAction from the futures assembly when I need a "reusable widget" of sorts. It has it s own controller and is better at handling more complex logic than a Partial View.
Finally, I tend to write Html Helper methods for things I may use in other projects (like paging links, etc).
I would use a partial view for complex things. Check out this article
Controls in MVC don t generally have (any) code behind. You use PartialViews as ascx controls, you pass them a model and you display the contents of the model.
You can create custom controls in mvc and these compile to a dll which is moveable between projects etc and these are a little more complex but essentially they spit out html like the partial view does.
You can also create jQuery plugins that are pretty cool and again, they can spit out html based on a model.
So a typical mvc view may be comprised of several partial views each of which are dedicated to a model or hierarchy of models.
Partial views can also display partial views so you can send a complex model to a partial view which in turn renders other partial views each of which deal with a more atomic part of your model.
I ve been writing a lot of my own HtmlHelper extension functions. The November meeting of http://www.c4mvc.net/ that was recorded today gives some great examples of control type code placed in HtmlHelper extension functions. The recording should be online soon.
You may also want to check out the Telerik Extensions for ASP.NET MVC. They re open source, so even if you don t use their controls, you can get some insight into controls in ASP.NET MVC by taking a look at how a commercial control vendor approached the problem.
Coming from a PHP turned webforms turned ASP.NET MVC background, I find myself relying a lot more on basic html/css/javascript.
I ve never been a fan of controls, even with webforms because they always ended up being messy compared to js/html/css counterparts.
I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...
I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...
What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...
let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...
I started out this morning working with my ASP.NET MVC project like normal and everything worked. I added a new class and some functions and it still worked. Then, all of a sudden, while I was ...
I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...
So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...
i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...