大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
在前台用JS写的脚本方法,除了可以直接用在前台控件的属性中,还可以在后台运用。 即在后台页面加载时,调用JS方法。
语法格式有两种,
如下:
1.第一种写法:控件ID名.Attributes.Add(“事件名称”,“JS方法”);
如:一个按钮控件Button1.Attributes.Add(“onclick”,“return confirm(‘确认?’)”);
2.另一写法:控件ID名.Attributes[“事件名称”]=“JS方法”;
如:前台写了一个JS方法: function ISCheck(){。。。。。。}; Button1.Attributes[“onclick”]=”ISCheck()”;
编程实战:
this.txtBeginDate.Attributes[“onclick”] = “return showCalendar(‘” + this.txtEmpName.ClientID + “‘,’y/mm/dd’)”;
this.txtBeginDate.Attributes.Add(“onclick”, “return showCalendar(‘” + this.txtEmpName.ClientID + “‘,’y/mm/dd’)”);
//以上两种方法是等效的
this.txtBeginDate.Attributes[“readonly”] = “true”; //在txtBeginDate中添加readonly为True的属性。
this.txtBeginDate.Attributes.Add(“readonly”, “true”); //等效的写法
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/189352.html原文链接:https://javaforall.net