Community Page
- www.emadibrahim.com Jump to website »
-
Subscribe -
Community
-
Top Commenters
-
Popular Threads
-
Recent Comments
- Good question. I actually don't test it and I have forgotten to add a few items before but unfortunately, it is a runtime error. What I would rather do but I am too lazy to is have this...
- One more thing I only thought about once I was implementing your technique in my project: How do you test your StandardModule.Load bindings? I'm sure I'll forget adding one of those sooner...
- Excellent post! I've been looking for a way to DRY up my own code as well and your post led me on the right way.
- Thanks a lot.It works also with SQL Server 2008 Express and NetworkService instead of LocalSystem.
- There is another validation toolkit called Validator Toolkit for ASP.NET on Codeplex.com. See http://www.codeplex.com/MvcValidatorToolkit
Jump to original thread »
ASP.NET MVC Preview 5 introduce the ModelBinder attribute that can be used to decorate a complex type in an Action. This allows us to have actions that look like this
public ActionResult Create([ModelBinder(typeof(GenericBinder))] ContactList myList)
... Continue reading »
public ActionResult Create([ModelBinder(typeof(GenericBinder))] ContactList myList)
... Continue reading »
10 months ago
10 months ago
documentation. But I just found some info at
http://weblogs.asp.net/scottgu/archive/2008/09/...
I will update the post to direct readers there.
Thanks for the heads up.
10 months ago
btw: this threaded comment view is awesome
10 months ago
moderate my comments. I simply reply to a comment with "approve" and it
gets approved. Or If I reply with some other text, it approves the comment
and submits my text as a comment. Very neat.
I am looking into the ComplexModelBinder and trying to get things working
with the built-in stuff :)
10 months ago
How do you use it? Why the need to 'register' it.
Seems to me if you pass a complex type as a parameter, it would map the form variables to the type with reflection - and only if you need to have more complex mapping would you create a specific binder...
10 months ago
I exposed the protected UpdateModel in my controller:
public void UpdateModel(BusinessSavingsRequest bsr, string[] keys)
{
base.UpdateModel(bsr, keys);
}
and then call it from my binder:
public object GetValue(ControllerContext controllerContext, string modelName, Type modelType, ModelStateDictionary modelState)
{
BusinessSavingsRequest bsr = new BusinessSavingsRequest();
string[] properties = typeof(BusinessSavingsRequest).GetProperties().Select(p => p.Name).ToArray();
((MvcApplication.Controllers.BusinessSavingsController)controllerContext.Controller).UpdateModel(bsr, properties);
return bsr;
}
Perhaps if this is all it needed to do I wouldnt have a custom binder for the type.