This is a migrated thread and some comments may be shown as answers.

ComboBox, MVC and [Remote] attribute

0 Answers 64 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sergey
Top achievements
Rank 1
Sergey asked on 22 Sep 2012, 06:44 PM

I have some problem with remote validation.

There is part of model

[DisplayName("For User ID")]
[Remote("CheckUserID", "User", ErrorMessage="Must be from list or Empty")]
public Nullable<System.Guid> ForUserID { get; set; }

View

@(Html.Kendo().ComboBoxFor(model => model.ForUserID)
            .HtmlAttributes(new { style = "width: 200px;" })
           //.Name("ForUserID")
           .Filter("contains")
           .Suggest(true)
           .Text("Select user")
           .Placeholder("Select name if necessary")
           .DataTextField("UserName")
           .DataValueField("UserId")
           .AutoBind(true)
           .DataSource(source =>
                           {
                               source.Read(read =>
                                               {
                                                   read.Action("GetUserWithId", "User"); //Set the Action and Controller name
                                               })
                                   .ServerFiltering(false); //If true the DataSource will not filter the data on the client.
                           })
             
           //.Events(e => { e.Select("userNameChange"); })
                   .Events(e => { e.Change("userNameChange"); })
          )

And action in Controller  UserController

[HttpGet]
public ActionResult CheckUserID(String userIdString)
{
    if (Request.IsAjaxRequest())
    {
           bool result = true; 
        JsonResult res = Json(result, JsonRequestBehavior.AllowGet);
        return res;
    }
    return RedirectToAction("Index", "AccountBoost");
}

All javaScripts for validation included into page, client validation works with Text Input that is also on this page. 

 I can get into action when typing in browser /User/CheckUserID .

But I never get into  CheckUserID action if I work with ComboBox.

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Sergey
Top achievements
Rank 1
Share this question
or