Run C# code after running all javascript codes

Posted by Devi on Stack Overflow See other posts from Stack Overflow or by Devi
Published on 2009-08-17T07:39:05Z Indexed on 2010/04/16 3:03 UTC
Read the original article Hit count: 160

Filed under:
|

I am having a form in which a button is there on click of that button i am calling a javascript function in which i am displaying like 3.. 2.. 1 kind of effect then i am returning true.

But after showing 3 only return true is getting executed and the form is getting submitted.

How to stop form submitting before running the script.

Edit:

function jsFun() 
{ 
    timerCount(3); 
    //Calling the Timer Function. 
} 

var t; 

function timerCount(cDown) 
{ 
    if (cDown == 0) 
    { 
        clearTimeout(t); 
        return true; 
    } 

    $('#<%= mainContainer.ClientID %>').html(cDown); 
    cDown = cDown - 1; 
    t = setTimeout('timerCount(' + cDown + ')', 1000); 
} 

<asp:Button ID="btnStarts" runat="server" Text="Start" OnClientClick="return jsFun();" OnClick="btn_click" />

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript