using System;
using System.Collections.Generic;
using System.Text;
namespace Core
{
public abstract class Library
{
public static void PageJS(string strJS)
{
System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler;
if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "clientScript"))
{
page.ClientScript.RegisterStartupScript(page.GetType(), "clientScript",
"<script language=javascript>" + strJS + "</script>");
}
}
public static void PageMessage(string strMsg)
{
System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler;
if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "clientScript"))
{
page.ClientScript.RegisterStartupScript(page.GetType(), "clientScript",
"<script language=javascript>alert('" + strMsg + "');</script>");
}
}
public static void PageMessage(string strMsg,string url)
{
System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler;
if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "clientScript"))
{
page.ClientScript.RegisterStartupScript(page.GetType(), "clientScript",
"<script language=javascript>alert('" + strMsg + "');window.location.href='" + url + "';</script>");
}
}
/// <summary>
/// 判断2个字符串内是否有相同字符,请将较大的字符串放在前面传入
/// </summary>
/// <param name="strFirst"></param>
/// <param name="strSecend"></param>
/// <returns></returns>
public static bool strEqule(string strFirst, string strSecend)
{
for (int i = 0; i < strSecend.Length; i++)
{
if(strFirst.Contains(strSecend.Substring(i,1)))
{
return true;
}
}
return false;
}
}
}
本文介绍了一个用于ASP.NET应用程序的实用类库,该类库提供了在页面上注册JavaScript脚本和显示消息的功能,并实现了一个字符串比较的方法。通过这些功能,可以简化常见的Web开发任务。
19万+

被折叠的 条评论
为什么被折叠?



