LinkButton is not calling JavaScript function in OnClick?
asp.net, c#, jquery
Solution
OnClick is for specifying handlers in code-behind. If you want to specify a javascript function, you should use OnClientClick attribute.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.onclientclick(v=vs.80).aspx
Problem
I'm trying to call a jquery function from a asp link button. Here is my link button html: ``` <div style="padding-left:75px"> <asp:LinkButton ID="lbAddCC" runat="server" ClientIDMode="Static" OnClick="ShowCCControls()" Text="Add CC"></asp:LinkButton> </div> ``` Here is my jquery function: ``` function ShowCCControls() { $('#lblCC').show(); $('#txtCC').show(); } //end ShowCCControls() ``` When I try to build, I get the error: ASP.internal_email_aspx does not contain a definition for 'ShowCCControls' and no extension method 'ShowCCControls' accepting a first argument of type 'ASP.internal_email_aspx' could be found (are you missing a using directive or an assembly reference?) I have this working on another page using a check box: ``` <asp:CheckBox ID="chkNew" TabIndex="8" runat="server" Text="New Tank" OnClick="SetNewTankControls()" ClientIDMode="Static" /> ``` Anybody see an issue? Thanks Here is all of the javascript: ``` <script type="text/javascript" language="javascript"> //document.ready is used for jquery, waits until the doc is ready to be manipulated $(document).ready(function () { HideControls(); }); //end document.ready function HideControls() { $('#lblCC').hide(); $('#txtCC').hide(); $('#lblBCC').hide(); $('#txtBCC').hide(); } //end HideControls() function ShowBCCControls() { $('#lblBCC').show(); $('#txtBCC').show(); } //end ShowBCCControls function ShowCCControls() { $('#lblCC').show(); $('#txtCC').show(); } //end ShowCCControls() ```