문제

Why is IE behaving like this? It works fine on Chrome and firefox so i got this in

view.ascx

<% using (Ajax.BeginForm("Action1", "TheController", new { pid= Request.QueryString["pid"] }, new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "POST", UpdateTargetId = "setting-modal-body", OnSuccess = "fnPreloadAttr" }, new { @class = "form-horizontal", id = "setting-edit-form" }))
                   {%>
                <div id="setting-modal-body" class="clearfix">
                    <%Html.RenderPartial("SettingModal"); %>
                </div>
                <%}   %>

TheController.cs

    [HttpPost]
            public ActionResult Action1(SettingModel setModel)
            {
                ModelState.Clear();
setModel.Aa="1";                
                return PartialView("SettingModal", setModel);
            }

it works fine and replacing the content of setting-modal-body but shortly after that IE redirect the page to Action1 because of 'onload' event, how to prevent that from happening?

도움이 되었습니까?

해결책

Giving up on using ajax.beginform, it just doesn't return false after onsubmit is done, so I use this instead

  <form action="/TheController/Action1?pid=<%=Request.QueryString["pid"] %>" class="form-horizontal" id="setting-edit-form" method="post" onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, httpMethod: 'POST', updateTargetId: 'setting-modal-body', onSuccess: Function.createDelegate(this, fnPreloadAttr) });return false;">

mvc2 ajax is not good

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top