1.错误示范:
此处txtCopmStarTime调用laydate()方法,使用txtReportStartTime.Attributes.Add(“onfocus”,"");可以控制其为只读状态,但是调用js文件绑定text的方法,如txtReportEndTime却无法设置为只读,txtReportEndTime.ReadOnly/Enabled也 都不可以
2.正确方法:
延迟调用js文件,在用的到的时候在调用js文件,即在后台调用,调用时可以对当前登录人身份进行判断,是否可以对日期控件进行操作,再决定是否调用该js文件。
if (Session[ConstHelper.Session_Login_Stu] != null)
{
this.Page.ClientScript.RegisterClientScriptInclude("", this.Context.Response.ApplyAppPathModifier("~/js/laydate.js"));
}