开发者

How to use an actionresult to return both a view and a partial view

开发者 https://www.devze.com 2023-02-12 02:46 出处:网络
How can I use use an actionResultto return both a view and a partial view.Actually in case of an ajax request it should send a partial view else it should send a view.

How can I use use an actionResult to return both a view and a partial view. Actually in case of an ajax request it should send a partial view else it should send a view.

   public ActionResult Test(string Name ="", DateTime? Date= null, string sex="" )
         {            
             myModel model = new myModel(Name, Date, Sex);
             if(IsAjaxRequest)
                 return PartialView("partialView", model)
             else
                 开发者_开发技巧return View(model);
         }


if (Request.IsAjaxRequest())
    return PartialView("_Article", model);

return View(model);
0

精彩评论

暂无评论...
验证码 换一张
取 消