2012-08-15 55 views
0
[Remote("DropDownSelected", "Patient")] 
public Guid SexIdentifier { get; set; } 



public ActionResult DropDownSelected(object value) 
{ 
    var x = ((Guid)value).ToString(); 
    string xsd = value.ToString(); 
    var abc = ControllerContext.Controller; 

    if (value == null) 
    { 
     //value = string.Empty; 
    } 

    if (value.ToString() == Convert.ToString(Guid.Empty) || value.ToString() == string.Empty) 
    { 
     return Json(String.Format("0 does not exist."), JsonRequestBehavior.AllowGet); 
    } 

    return Json(true, JsonRequestBehavior.AllowGet); 
} 

回答

0

工作。如果你的財產被稱爲SexIdentifier那麼你的動作必須使用相同的名稱,它的參數:如果你有,你可以使用下拉菜單的默認值

public ActionResult DropDownSelected(Guid sexIdentifier) 
{ 
    ... 
} 

而且一個可空Guid

public ActionResult DropDownSelected(Guid? sexIdentifier) 
{ 
    ... 
} 
+0

但我需要使用此驗證的多個屬性 有什麼辦法,我可以給一個共同的別名 – 2012-08-15 10:02:10

+0

你可以試試從POST正文讀取它:'Request.Form [0]'。 – 2012-08-15 10:05:13

+0

thanx it workss – 2012-08-16 05:23:17