I am trying to call a javascript function on click of a button (server control).When i use html button control (with a runat="server" attribute) for the above purpose, am able to do it ,
but when I use ASP.net Button control (web control), It gives me the
error: BC30456: 'myFunction' is not a member of 'ASP.webform1_aspx'.
What is the difference ?
For case 1 my code using html button control, case 2 is my code using ASP.net web control:
case 1:
<html>
<head>
<script >
function myFunction()
{
alert("Hello World!");
}
</script>
</head>
<body>
<button runat="server" onclick="myFunction()">Try it</button>
</body>
</html>
** case 2:**
<html>
<head>
<script >
function myFunction()
{
alert("Hello World!");
}
</script>
</head>
<body>
<asp:Button id="Button" onclick="myFunction()" runat="server" Text="Button" />
</body>
</html>