PDA

View Full Version : [CLOSED] MVC RAZOR remotevalidation datefield select event



zwf
Oct 12, 2012, 10:03 AM
Hi,

this doesn't seem to work :



Html.X().DateFieldFor(m => m.ES_TRANS_DATUM)
.ID("date_ES_TRANS_DATUM")
.LabelAlign(LabelAlign.Top)
.Width(150)
.FieldLabel("Transportdatum")
.Control(c =>
{
c.IsRemoteValidation = true;
c.RemoteValidation.Url = "/Home/isDateValid";
c.RemoteValidation.Method = Ext.Net.HttpMethod.POST;
c.RemoteValidation.ValidationEvent = "SELECT";
c.MsgTarget = MessageTarget.Under;
//c.RemoteValidation.Json = true;
}
)

The above doesn't work ! Any ideas why ? What am I doing wrong ?
If I remove
c.RemoteValidation.ValidationEvent = "SELECT"; it works only when I'm typing, but not
when I select a date from the popup.
I need the remotevalidation to work with "SELECT" AND when typing the date ......
How can I do this ?

Regards,
Holger

PS: When I look at the network traffic, no XHR is happening......

Daniil
Oct 12, 2012, 10:46 AM
Hi Holger,

I think the event name should be lowercase.

c.RemoteValidation.ValidationEvent = "select";

zwf
Oct 12, 2012, 2:02 PM
Hi Holger,

I think the event name should be lowercase.

c.RemoteValidation.ValidationEvent = "select";

This doesn't work .....
No XHR happens .....

Perhaps, because of the datefield ? Is it another event ?

Regards,
Holger

Daniil
Oct 12, 2012, 2:52 PM
You should set EventOwner. Also please use the RemoteValidation property.

Example

Html.X().DateFieldFor(m => m.DateTimeValue)
.IsRemoteValidation(true)
.RemoteValidation(rv =>
{
rv.Url = Url.Action("validation handler URL");
rv.ValidationEvent = "select";
rv.EventOwner = ValidationEventOwner.Field;
})

zwf
Oct 12, 2012, 4:10 PM
You should set EventOwner. Also please use the RemoteValidation property.

Example

Html.X().DateFieldFor(m => m.DateTimeValue)
.IsRemoteValidation(true)
.RemoteValidation(rv =>
{
rv.Url = Url.Action("/Home/isDateValid");
rv.ValidationEvent = "select";
rv.EventOwner = ValidationEventOwner.Field;
})

It gets fired, but in the



public JsonResult isDateValid(string date)
{

JsonResult result = new JsonResult();
Object Data;


date is always null........


OK. I found it out :



public JsonResult isDateValid(string value) <-----
{

JsonResult result = new JsonResult();
Object Data;