There is an issue that I'm facing:
I have developed an ASP.NET page which includes an Update panel with an ASP.NET control.
I have a JavaScript function for validation. When the button is clicked, I want to use onclientclick to trigger the JavaScript validation function first and then call the event click button function from code behind.
I have tried several methods but none of them seem to work for me.
Below is a snippet of my code where after clicking the button, onclientclick triggers the JavaScript function for validation, and if the validation passes, it should call the 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
}