"
public static class Helper
{
public static readonly string【】 alertMessage = new //代码效果参考:https://v.youku.com/v_show/id_XNjQwMDIwMTg2OA==.html
string【】 { ""创建成功!"", ""创建失败???"", ""修改成功!"", ""修改失败???"", ""删除成功!"", ""删除失败???"" };public static void Alert(Page currentPage, string msg)
{
//currentPage.ClientScript.RegisterClientScriptBlock(currentPage.GetType(), ""alert"", ""alert(\"""" +
// HtmlUtil.ConvertAlertMessage(msg) + ""\"");"", true);
string csname = ""alert"";
Type cstype = currentPage.GetType();
if (!currentPage.ClientScript.IsStartupScriptRegistered(cstype, csname))
{
currentPage.ClientScript.RegisterStartupScript(cstype, csname, ""alert(\"""" +
//代码效果参考:https://v.youku.com/v_show/id_XNjQwNjYzOTIwOA==.html
HtmlUtil.ConvertAlertMessage(msg) + ""\"");"", true);}
}
public static void AlertImmediately(Page currentPage, string msg)
{
currentPage.Response.Write(""alert(\"""" +
HtmlUtil.ConvertAlertMessage(msg) + ""\"");"");
}
public static void AlertAndBack(Page currentPage, string msg)
{
Alert(currentPage, msg);
currentPage.ClientScript.RegisterClientScriptBlock(currentPage.GetType(), ""back"", ""javascript:history.go(-1);"", true);
}
public static void AlertAndBack(Page currentPage, string msg,string path)
{
Alert(currentPage, msg);
currentPage.ClientScript.RegisterClientScriptBlock(currentPage.GetType(), ""back"", ""javascript:window.location = '"" + path + ""';"", true);
}
public static T GetRequestForm(HttpRequest request, string traget)
{
string orgid = request.Form【traget】.Trim();
return TypeConverd(orgid);
}
public static T GetQueryString(HttpRequest request, string traget)
{
string sendid = request.QueryString【traget】.Trim();
return TypeConverd(sendid);
}
public static T TypeConverd(string sendid)
{
Type t = typeof(T);
switch (t.FullName)
{
case ""System.Guid"":
Guid guid = new Guid(sendid);
return (T)(object)guid;
default:
break;
}
object obj = new object();
return (T)(obj);
}
}
"