Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top