1.通过控件的Attributes属性注册客户端JavaScript
   如在Page_Load中,Button1.Attributes.Add("onclick", "javascript:alert('多加注意!!!')");
 
2.通过Page.ClientScript.RegisterStartupScript和Page.ClientScript.RegisterClientScriptBlock方法
   如Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "MyJavaScriptFile.js");
   两者的区别是:前者包含在<form>内的最后面,后者位于<Form>外面的最前面。
   每段脚本都包含一个名称参数,同名的参数不能用来注册两段脚本。开发者通过Page.ClientScript.IsClientScriptBlockRegistered属性判断。

相关文章:

  • 2021-05-15
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2021-07-23
  • 2021-08-23
  • 2022-12-23
猜你喜欢
  • 2021-05-19
  • 2021-08-01
  • 2021-11-26
  • 2022-12-23
  • 2021-12-25
  • 2021-05-24
  • 2022-12-23
相关资源
相似解决方案