calling java script function then C# function after clicking ASP.NET button

Posted by Eyla on Stack Overflow See other posts from Stack Overflow or by Eyla
Published on 2010-03-12T02:12:56Z Indexed on 2010/03/12 2:17 UTC
Read the original article Hit count: 253

Filed under:
|
|

I have this serious:

I have ASP.NET page, This page contents Update panel with ASP.NET control.

I have Java script function to do validation so when I click the button I will use onclientclick to call the java function to do the validation and after this one done should call then event click button function from code behind.

I tried vew methods but they did not work for me.

here is sample of my code that after I click the button onclientclick will call the java script function for validation and if the validation is OK should call onclick event.

.................... java script function ........................

    <script type="text/javascript" >

function add(){
 if (tag == trye) {


                         document.getElementById('<%=btnInfor.ClientID%>').click();
                         alert("DataAdded")



                    }
                    else {

                          alert("Requiered Field Missing.")
                        return false;

                     }
}

</script> 
.....................
ASP.NET button
...................
<asp:Button ID="btnInfor" runat="server" Text="Add Information" Style="position: absolute;
                top: 1659px; left: 433px;" 
                onclientclick="JavaScript: return myAdd()" />
....................
code behind in C#
......................
 protected void btnInfor_Click(object sender, EventArgs e)
        {    
                \\mycode

}

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript