|
-
Feb 4th, 2011, 07:39 AM
#1
Thread Starter
Hyperactive Member
Model Binding - Bind Attribute with Conditional Prefix
My fields in my form are prefixed, so the default model binding will not bind them by default.
Solved the problem using the "Prefix" method of the "Bind" attribute, which works just great:
public ActionResult CreateChild([Bind(Prefix = "FirstChild")] ChildViewModel model)
Now the thing is, the moment I hit this method, I have to figure out what the Prefix should be. It's based on a member in my ViewModel (If ViewModel.Mode == "This", Prefix = "MyOnePrefix", else "Prefix = "MOtherPrefix")
Can this be done in one way or another?
It would be cool if "Prefix" could take a list of strings like "Exclude" and "Include" does. (Tried..won't work)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|