首页 > 编程 > C# > 正文

c#注册客户端事件示例

2020-01-24 02:49:08
字体:
来源:转载
供稿:网友

复制代码 代码如下:

/// <summary>
 /// 注册客户端CSS文件
 /// </summary>
 /// <param name="page"></param>
 /// <param name="relativeURL"></param>
 public static void RegisterClientCSSFile(Page page, string relativeURL)
 {
     relativeURL = page.ResolveUrl(relativeURL);
     page.Header.Controls.Add(new LiteralControl("/n<link href=/"" + relativeURL + "/" rel=/"stylesheet/" type=/"text/css/">/n"));
 }
 /// <summary>
 /// 网页延迟退出
 /// </summary>
 /// <param name="page"></param>
 /// <param name="script"></param>
 /// <param name="delayTime">以秒为单位?</param>
 public static void ClosePage(Page page, string script, int delayTime)
 {
     string closeScript. = "";
     closeScript. += "<script. language=javascript>";
     closeScript. += "setTimeout(/"ClosePage()/","+ (delayTime * 1000).ToString()+");";
     closeScript. += "function ClosePage(){window.close();"+script+"};";
     closeScript. += "</script>";

     page.ClientScript.RegisterClientScriptBlock(page.GetType(), "ClosePage",
  closeScript);
 }
 /// <summary>
 /// 注册客户端脚本文件
 /// Creator: Create Time:2009/7/22 13:47:20
 /// </summary>
 /// <param name="page"></param>
 /// <param name="key"></param>
 /// <param name="relativeURL"></param>
 public static void RegisterClientScriptFile(Page page, string key, string relativeURL)
 {
     relativeURL = page.ResolveUrl(relativeURL);
     if (!page.ClientScript.IsClientScriptIncludeRegistered(key))
     {
  page.ClientScript.RegisterClientScriptInclude(key, relativeURL);
     }
 }

 /// <summary>
 ///
 /// </summary>
 /// <param name="control"></param>
 public static void AutoBreakWord(WebControl control)
 {
     if (control != null)
     {
  control.Style.Add("word-break", "break-all");
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="control"></param>
 public static void DisablePaste(WebControl control)
 {
     if (control != null)
     {
  control.Attributes.Add("onpaste", "event.returnValue=false;");
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="control"></param>
 public static void DisableKeyDown(WebControl control)
 {
     if (control != null)
     {
  control.Attributes.Add("onkeydown", "event.returnValue=false;");
     }
 }

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表