Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm learning Javascript i try to write the "HelloWorld" Program it causes some errors like 

error: CS1026: ) expected

Line 18:     <form id="form1" runat="server">
Line 19:     <div>
Line 20:     <asp:Button runat="server" ID="btlDate" Text="Display Date"                          OnClick="javascript:dispdate();" />
Line 21:     </div>
Line 22:     </form>
 

 
do you know what could be wrong with this code?

C#
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    
    <script type="text/javascript" language="javascript">
        function dispdate() 
        {
            alert("Hello World");
        }
    </script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Button runat="server" ID="btlDate" Text="Display Date" OnClick="javascript:dispdate();" />
    </div>
    </form>
</body>
</html>
Posted

1 solution

OnClick[^] is a Server side Event.

Use OnClientClick[^] instead of OnClick.

Another Example - Button OnClientClick Property[^]
 
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