model.addattribute的作用___attribute__

发布时间:2025-12-09 14:15:58 浏览次数:2

在前台用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://www.cnblogs.com/hell-world/p/5258111.html

需要做网站?需要网络推广?欢迎咨询客户经理 13272073477