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>
posted @ 2012-08-28 17:22  iDEAAM  阅读(206)  评论(0编辑  收藏  举报