calling java script function then C# function after clicking ASP.NET button
- by Eyla
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
}