Click here to Skip to main content
15,922,630 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written javascript function in script tag in asp page and called the function OnClick event of a button.
But when I click the button it does not work and show an error message that button does not contain a function that I declared above. Please help me.
Mohi Uddin
Posted
Comments
OriginalGriff 10-Mar-13 5:32am    
Show us the code - at the moment we would have to guess.
Use the "Improve question" widget to edit your question and provide better information - just the relevant code fragments, please!

1 solution

i'm giving you an example it will help you

XML
<script type="text/javascript">
    function validate()
     {
    if(document.getElementById("<%=txtName.ClientID %>").value == 0)
      {
        alert("Please Enter Name");
        document.getElementById("<%=txtName.ClientID %>").focus();
        return false;
      }
</script>

<asp:button id="btnAdd" text="Add" runat="server" onclientclick="javascript:return validate();"/>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900