MVC 3.0 MicrosoftAjax 的使用
@model TestMVC.Areas.WebSite.Models.TestModel
@{
ViewBag.Title = "Index";
}
<h2>
Index</h2>
<script src="http://www.ideaam.com/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="http://www.ideaam.com/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<script src="http://www.ideaam.com/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
<script src="http://www.ideaam.com/Scripts/jquery.unobtrusive-ajax.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
var ideaam = (function ($) {
return {
success: function (data) {
Result.innerHTML = Result.innerHTML + "success";
},
failure: function () {
alert("failure");
}
}
} (ideaam));
</script>
@using (Ajax.BeginForm("Test", "Home", new AjaxOptions
{
HttpMethod = "Post",
OnSuccess = "ideaam.success",
OnFailure = "ideaam.failure",
UpdateTargetId = "ajaxResult",
InsertionMode = InsertionMode.Replace
}))
{
@Html.Label(Model.ID.ToString());
<span style="margin-left: 10px; float: left;"></span>
@Html.TextBoxFor(m => m.Title, "Title");
<span style="margin-left: 10px; float: left;"></span>
@Html.TextBoxFor(m => m.Description, "Description");
<input type="submit" value="Submit" />
}
<div id="ajaxResult">
</div>
<div id="Result">
</div>
@{
ViewBag.Title = "Index";
}
<h2>
Index</h2>
<script src="http://www.ideaam.com/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="http://www.ideaam.com/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
<script src="http://www.ideaam.com/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
<script src="http://www.ideaam.com/Scripts/jquery.unobtrusive-ajax.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
var ideaam = (function ($) {
return {
success: function (data) {
Result.innerHTML = Result.innerHTML + "success";
},
failure: function () {
alert("failure");
}
}
} (ideaam));
</script>
@using (Ajax.BeginForm("Test", "Home", new AjaxOptions
{
HttpMethod = "Post",
OnSuccess = "ideaam.success",
OnFailure = "ideaam.failure",
UpdateTargetId = "ajaxResult",
InsertionMode = InsertionMode.Replace
}))
{
@Html.Label(Model.ID.ToString());
<span style="margin-left: 10px; float: left;"></span>
@Html.TextBoxFor(m => m.Title, "Title");
<span style="margin-left: 10px; float: left;"></span>
@Html.TextBoxFor(m => m.Description, "Description");
<input type="submit" value="Submit" />
}
<div id="ajaxResult">
</div>
<div id="Result">
</div>