Click here to Skip to main content
16,018,458 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
hi sir,

how to apply javascript function to asp.net control. i am write
Show() function in javascript. and this function is apply in html control. like

<asp:Datagrid ..........
...
<asp:TemplateColumn>
<ItemTemplate>
<input id="chkSelect" type="checkbox" onclick="Show()" />
.....

i want to use server side checkbox instead of html checkbox. this time also i want javascript for asp.net checkbox control how to apply javascript function for server side control

please give a solution.

Thanks
Posted

you have to handle onclientclick event of a control. onclientclick="javascriptfunctioname();"
 
Share this answer
 
Comments
Sandeep Mewara 18-Jul-10 9:59am    
Reason for my vote of 1
Checkbox don't have OnClientClick property.
You can add javascript to server side controls using the 'Attribute' property.

Example:
<asp:CheckBox id="myChB" runat="server"></asp:Checkbox>

C#
//Server Side code  

myChB.Attributes.Add("onclick","javascript:MyJSMethodToExecuteOnClick();");
 
Share this answer
 

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