当前位置: 编程技术>.net/c#/asp.net
c#注册客户端事件示例
来源: 互联网 发布时间:2014-10-28
本文导语: 代码如下:/// /// 注册客户端CSS文件 /// /// /// public static void RegisterClientCSSFile(Page page, string relativeURL) { relativeURL = page.ResolveUrl(relativeURL); page.Header.Controls.Add(new LiteralControl("nn")); } /// /// 网页延迟退出 /// ///...
代码如下:
///
/// 注册客户端CSS文件
///
///
///
public static void RegisterClientCSSFile(Page page, string relativeURL)
{
relativeURL = page.ResolveUrl(relativeURL);
page.Header.Controls.Add(new LiteralControl("nn"));
}
///
/// 网页延迟退出
///
///
///
/// 以秒为单位?
public static void ClosePage(Page page, string script, int delayTime)
{
string closeScript. = "";
closeScript. += "";
closeScript. += "setTimeout("ClosePage()","+ (delayTime * 1000).ToString()+");";
closeScript. += "function ClosePage(){window.close();"+script+"};";
closeScript. += "";
page.ClientScript.RegisterClientScriptBlock(page.GetType(), "ClosePage",
closeScript);
}
///
/// 注册客户端脚本文件
/// Creator: Create Time:2009/7/22 13:47:20
///
///
///
///
public static void RegisterClientScriptFile(Page page, string key, string relativeURL)
{
relativeURL = page.ResolveUrl(relativeURL);
if (!page.ClientScript.IsClientScriptIncludeRegistered(key))
{
page.ClientScript.RegisterClientScriptInclude(key, relativeURL);
}
}
///
///
///
///
public static void AutoBreakWord(WebControl control)
{
if (control != null)
{
control.Style.Add("word-break", "break-all");
}
}
///
///
///
///
public static void DisablePaste(WebControl control)
{
if (control != null)
{
control.Attributes.Add("onpaste", "event.returnValue=false;");
}
}
///
///
///
///
public static void DisableKeyDown(WebControl control)
{
if (control != null)
{
control.Attributes.Add("onkeydown", "event.returnValue=false;");
}
}