MVC3 razor remote validation - Controller argument

2019-07-28 04:58发布

I can call the controller but the argument (string) is always null.

All the examples I have found name the controller argument the same as the property we are validating remotely, sounds good/easy, but if you look at fiddler what is really being passed in is the name attribute from the input statement. Well that is problematic in that it is a subscripted name something like Person.EMailAddresses[0].Address, well I can't name my controller parameter like that.

So how do I get around this? There must be a way to specify the controllers parameter name in the remote() attribute?

1条回答
Animai°情兽
2楼-- · 2019-07-28 05:53

It cannot be done using the default RemoteAttribute. This is a link to an example I posted of a reusable remote validation attribute, where you can specify the name of the controller, action and the name of the variable used to pass the value to the action.

查看更多
登录 后发表回答