这是我的控制器动作方法......从那个动作我想要返回一个有条件的部分视图......并在ajax成功方法中显示这个局部视图....
public ActionResul InsertPestType (PestTypeViewModel model)
{
if (ModelState.IsValid == true)
{
pest_type emp = new pest_type();
ViewBag.emp = db.pest_type.SingleOrDefault(x => x.pest_type_name
== model.pest_type_name && x.isdeleted == false);
if (ViewBag.emp != null)
{
emp = ViewBag.emp;
}
if (emp.pest_type_name == model.pest_type_name)
{
ViewBag.Message = "This Pest Type is already exist in the
record";
return PartialView("Insert_PestType", model);
}
else
{
emp.pest_type_name = model.pest_type_name;
emp.isdeleted = false;
db.pest_type.Add(emp);
db.SaveChanges();
List<pest_type> model1 = db.pest_type.Where(x => x.isdeleted
== false).ToList();
ViewBag.pesttypelist = model1;
return PartialView("pest_type_partial", model);
}
}
else
return PartialView("inex_partial", model);
}
下面是我的ajax成功方法.......这里我想只显示一个部分视图,这是真的根据条件...........现在我的问题是,怎么能我在ajax成功方法中区分了两个局部视图??
var success = function(response) {
if ()
{
$("#RegisterPestTypeModel").modal('hide')
$("#dvCategoryResults").html(response.AjaxReturn)
}
else
{
$("#PestTypeModalBody").html(response)
}