asp.net mvc - MVC Remote Validation With Additional bool Fields -
I'm trying to use remote validation with an additional boole checkbox field
< Code> [Remote ("iStoreconnectionWalid", "Tant Management", Additional Fields = "Creatstose")] Public String Storage Connection Connection String {get; Set; }Verification code
public JsonResult IsStorageConnectionValid (String Structure Connection String, bool createStorage) {
This is completely Works according to the condition of killing the validator. However, despite the value of the checkstock, the text store is always correct if I use an additional field which is not a check box, they are fully supplied.
The checkbox is created as standard:
@ Html.CheckBoxFor (m => m.CreateStorage) < P> Is this a bug? Or am I doing it wrong?
It seems that this is a bug when
@ html. CheckBoxFor is used with . The problem is that a hidden with check box with
checkbox 2 elements,
value = "true" and
value = "false" (uncheck) The input given does not post the checkbox back, so the other hidden input ensures that a value is posted back for use by
DefaultModelBinder
< Code> jquery.validate are viewing the relevant section of Unobtrusive.js file
adapter.ed ("remote", ["url", "type", "ex "Field = {url: Options.params.url, type: options.params.type ||" GET ", data: {}}, prefix = getModelPrefix (options.element.name) ; $ .each (Split Endreme (options.params.additionalfields || Options.eletion.name), function (i, fieldName) {var paramName = appendModelPrefix (field name, prefix); value.data [paramName] = function () { Return ($: options.form). Find (": input [name = '" + + Aptitude Value + "']"). Val ();};}); Set Validation Value (option, "Remote" Values);});
returns the
return statement (in your case)
.find (': input [name = "CreateStorage"]'). Val (); returns the value of first input with
name = "CreateStorage" , which will always be
true (the value of the checkbox) / P>
As a test, if you provide a value using
hidden , then the
checkbox will send you your
IsStorageConnectionValid Method (but of course it helps because you can not change the value)
The best solution is not sure, but the
disorganized script Area should be checked if
.find (..) returns more than one element, if unchecked the first box, the other returns the value of the element.
Edit
I made it a
Edit 2
I have been informed that the issue is now >
Comments
Post a Comment