后台静态弹出窗口

public static class Helper
    {

        public static readonly string[] alertMessage = new 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(\"" +
                    HtmlUtil.ConvertAlertMessage(msg) + "\");", true);
            }
        }

        public static void AlertImmediately(Page currentPage, string msg)
        {
            currentPage.Response.Write("<script type='text/javascript'>alert(\"" +
                HtmlUtil.ConvertAlertMessage(msg) + "\");</script>");
        }

        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<T>(HttpRequest request, string traget)
        {


            string orgid = request.Form[traget].Trim();
            return TypeConverd<T>(orgid);

        }
        public static T GetQueryString<T>(HttpRequest request, string traget)
        {
            string sendid = request.QueryString[traget].Trim();

            return TypeConverd<T>(sendid);


        }
      
        public  static T TypeConverd<T>(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);
        }

    }
posted @ 2011-06-15 16:37  Smallen  阅读(158)  评论(0)    收藏  举报