@{ ViewBag.Title = "Home Page"; Layout = "~/views/shared/_Layout.cshtml"; } <div id="tardiv"></div> @using (Ajax.BeginForm("PartialView1", new AjaxOptions(){ UpdateTargetId = "tardiv"})) { <input type="submit" value="Refresh" /> } <br />
<!DOCTYPE html> <html> <head> <title>@ViewBag.Title</title> <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> <script src="@Url.Content("~/Scripts/microsoftajax.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type="text/javascript"></script> </head> <body> @RenderBody() </body> </html>
public string PartialView1() { var bajax = Request.IsAjaxRequest(); // always false!!! return "wxyz"; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)