Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

AjaxOptions not working in Ajax.BeginForm

$
0
0

I am trying to use busy indicator in my applicataion. I am using MVC4.

This is my view code:

(Index.aspx)

<script type="text/javascript">
    function onBegin() {
        
        $("#divLoading").html('<image src="../Content/ajax-loader.gif" alt="Loading, please wait" />');
    }
    function onComplete() {
        
        $("#divLoading").html("");
    }
    function onSuccess(context) {
        
        var d = new Date();
        var day = d.getDate();
        var month = d.getMonth() + 1;
        var year = d.getFullYear();

        $("#divLoading").html("Current Date and Time " + day + "." + month + "." + year + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds());
    }
  </script>


<h2>Index</h2>
<div id="divLoading">   
    </div>
    <% using (Ajax.BeginForm("GetData","Home", new AjaxOptions { UpdateTargetId = "Result", OnSuccess = "onSuccess", OnBegin = "onBegin", OnComplete = "onComplete" }))
       { %>

       <%= Html.TextBox("Name") %>

        <input type="submit" value="Submit" /><br />
    <h1>
        <span id="Result"></span>
    </h1>
    <% } %>

</asp:Content>

My Controller:

public ActionResult Index()
        {            
            return View();
        }

        public string GetData(string Name)
        {
            return Name;
        }

When click on button, it s'd display a busy indicator, and after completion the result. But instead of showing a busy indicator, the page redirect to a new page with controller action name (GetData) and display the result in tht page.  None of my AjaxOptions is being called. I have included all Jquery files. No errors abut still the code is not working. Can anyone help??


Viewing all articles
Browse latest Browse all 5678

Latest Images

Trending Articles



Latest Images