close


/// <summary>
        /// 支援Page與UpdatePanel 的alert message
        /// </summary>
        /// <param name="infomation"></param>
        /// <param name="control"></param>
         public static void Show(string infomation, Control control)
         {
            bool isPage = (control is Page);
            bool isUpdatePanel = (control is UpdatePanel);

            if (!isPage && !isUpdatePanel)
            {
                throw new ArgumentException("訊息只能輸出到Page或者UpdatePanel中");
            }

            bool addScriptTags = true;
            string script = string.Format("window.alert('{0}');", infomation);
            string key = string.Format("WebMessageBox{0}", DateTime.Now.ToString());
            Type registerType = typeof(WebMessageBox);

            if (isPage)
            {
                Page page = control as Page;
                page.ClientScript.RegisterClientScriptBlock(registerType, key, script, addScriptTags);
            }

            if (isUpdatePanel)
            {
                UpdatePanel updatePanel = control as UpdatePanel;
                ScriptManager.RegisterClientScriptBlock(updatePanel, registerType, key, script, addScriptTags);
            }
         }

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 11 的頭像
    11

    冠霖的部落格

    11 發表在 痞客邦 留言(1) 人氣()