PDA

View Full Version : [CLOSED] [MVC] How to get json values after RemoteValidation



UnifyEducation
Mar 14, 2013, 1:59 PM
Hi,

I have a TextField with RemoteValidation

Views:

Html.X().TextField().ID("advisor_id1")
.FieldLabel("advisor_id1").MsgTarget(MessageTarget.Side).ValidateOnBlur(tru e)
.IsRemoteValidation(true)
.RemoteValidation(r =>
{
r.Url = Url.Action("CheckAdvisor2", "Resource");
r.Method = HttpMethod.POST;
r.Json = true;
//r.Complete = "App.int_advisor_id1.setIndicator(response)";
})

Controllers:

public JsonResult CheckAdvisor2(string value)
{
var resource = "valid";
return new JsonResult
{
Data = resource == value
? new { valid = true, message = "ok" }
: new { valid = false, message = "invalid" }
};
}

My question is how I can get json values after validations. For examples: Set indicator text of this textfield with Listeners (RemoteValidationFailure, RemoteValidationValid,...)

Thank you,

Daniil
Mar 14, 2013, 3:58 PM
Hi @UnifyEducation,

You are on the right road using a Complete handler.

r.Complete = "alert(el.serviceResponse.message)";

UnifyEducation
Mar 14, 2013, 5:52 PM
Hi @UnifyEducation,

You are on the right road using a Complete handler.

r.Complete = "alert(el.serviceResponse.message)";

Thank you, it works now.


r.Complete = "alert(el.message)";