如何将JavaScript函数应用于asp.net控件? [英] how to apply javascript function to asp.net control?

查看:57
本文介绍了如何将JavaScript函数应用于asp.net控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,

如何将JavaScript函数应用于asp.net控件.我在写
javascript中的Show()函数.并且此功能适用于html控件.喜欢

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

我想使用服务器端复选框而不是html复选框.这次我也希望javascript for asp.net复选框控件如何将javascript函数应用于服务器端控件

请提供解决方案.

谢谢

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

推荐答案

您可以使用''Attribute'' 属性将javascript添加到服务器端控件.

示例:
You can add javascript to server side controls using the ''Attribute'' property.

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


//Server Side code  

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


您必须处理控件的onclientclick事件. onclientclick ="javascriptfunctioname();"
you have to handle onclientclick event of a control. onclientclick="javascriptfunctioname();"


这篇关于如何将JavaScript函数应用于asp.net控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆