Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir I have one function in JavaScript -
function message()
{
}


But I am getting an error -"ASP.default_aspx' does not contain a definition for 'message' and no extension method 'message' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?)" in
XML
<div>
 <asp:Button ID="Button1" runat="server" onclick="message()" Text="Button"/>
</div>
Posted
Updated 24-Mar-11 20:29pm
v3
Comments
m@dhu 25-Mar-11 2:30am    
Subject line shortened.

Your Calling it on OnClick event
you need to call that on OnClientClick.
 
Share this answer
 
Comments
sairam.bhat 25-Mar-11 2:57am    
k thanks
As mahen25 said you need to call in onclientclick event
<asp:Button ID="Button1" runat="server" onclientclick="message()" Text="Button"/>

You need to register the Onclick event in pageload if you want to call the function server side.
C#
Button1.Attributes.Add("OnClick","message()");
 
Share this answer
 
Comments
sairam.bhat 25-Mar-11 2:56am    
K thanks

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