Exemple #1
0
        /// <summary>
        /// 获取显示确认对话框的客户端脚本
        /// </summary>
        /// <param name="message">对话框消息</param>
        /// <param name="title">对话框标题</param>
        /// <param name="icon">对话框图标</param>
        /// <param name="okScriptstring">点击确定按钮执行的客户端脚本</param>
        /// <param name="cancelScript">点击取消按钮执行的客户端脚本</param>
        /// <param name="target">弹出对话框的目标页面</param>
        /// <returns>客户端脚本</returns>
        public static string GetShowReference(string message, string title, MessageBoxIcon icon, string okScriptstring, string cancelScript, Target target)
        {
            //string msgBoxScript = "var msgBox=Ext.MessageBox;";
            //msgBoxScript += "if(parent!=window){msgBox=parent.window.Ext.MessageBox;}";
            if (String.IsNullOrEmpty(title))
            {
                title = "X.util.confirmTitle";
            }
            else
            {
                title = JsHelper.GetJsString(title.Replace("\r\n", "\n").Replace("\n", "<br/>"));
            }
            message = message.Replace("\r\n", "\n").Replace("\n", "<br/>");


            JsObjectBuilder ob = new JsObjectBuilder();

            ob.AddProperty("title", title, true);
            ob.AddProperty("msg", JsHelper.GetJsStringWithScriptTag(message), true);
            ob.AddProperty("buttons", "Ext.MessageBox.OKCANCEL", true);
            ob.AddProperty("icon", String.Format("{0}", MessageBoxIconHelper.GetName(icon)), true);
            ob.AddProperty("fn", String.Format("function(btn){{if(btn=='cancel'){{{0}}}else{{{1}}}}}", cancelScript, okScriptstring), true);

            string targetName = "window";

            if (target != Target.Self)
            {
                targetName = TargetHelper.GetScriptName(target);
            }
            return(String.Format("{0}.Ext.MessageBox.show({1});", targetName, ob.ToString()));
        }
Exemple #2
0
        /// <summary>
        /// 获取显示提示对话框的客户端脚本
        /// </summary>
        /// <param name="message">对话框消息</param>
        /// <param name="title">对话框标题</param>
        /// <param name="icon">对话框图标</param>
        /// <param name="okScript">点击确定按钮执行的客户端脚本</param>
        /// <param name="target">显示对话框的目标页面</param>
        /// <returns>客户端脚本</returns>
        public static string GetShowReference(string message, string title, MessageBoxIcon icon, string okScript, Target target)
        {
            #region oldcode

            //Ext.MessageBox.show({
            //           title: 'Icon Support',
            //           msg: 'Here is a message with an icon!',
            //           buttons: Ext.MessageBox.OK,
            //           animEl: 'mb9',
            //           fn: showResult,
            //           icon: Ext.get('icons').dom.value
            //       });

            //string msgBoxScript = "var msgBox=Ext.MessageBox;";
            //msgBoxScript += "if(parent!=window){msgBox=parent.window.Ext.MessageBox;}";

            //title = title.Replace("\r\n", "<br/>").Replace("\n", "<br/>");
            //message = message.Replace("\r\n", "<br/>").Replace("\n", "<br/>");

            //JsObjectBuilder ob = new JsObjectBuilder();
            //ob.AddProperty(OptionName.Title, String.Format("'{0}'", title), true);
            //ob.AddProperty(OptionName.Msg, String.Format("'{0}'", message), true);
            //ob.AddProperty(OptionName.Buttons, "Ext.MessageBox.OK", true);
            //ob.AddProperty(OptionName.Icon, String.Format("'{0}'", MessageBoxIconName.GetName(icon)), true);

            //return String.Format("box_getMessageBox({0}).show({1});", windowInstance, ob.ToString());

            #endregion

            if (title == null)
            {
                title = String.Empty;
            }

            message = message.Replace("\r\n", "\n").Replace("\n", "<br/>");
            title   = title.Replace("\r\n", "\n").Replace("\n", "<br/>");
            string targetScript = "window";
            if (target != Target.Self)
            {
                targetScript = TargetHelper.GetScriptName(target);
            }

            if (String.IsNullOrEmpty(title) && icon == DefaultIcon && String.IsNullOrEmpty(okScript))
            {
                return(String.Format("{0}.X.alert({1});", targetScript, JsHelper.GetJsString(message)));
            }
            else
            {
                return(String.Format("{0}.X.alert({1},{2},{3},{4});",
                                     targetScript,
                                     JsHelper.GetJsStringWithScriptTag(message),
                                     JsHelper.GetJsString(title),
                                     MessageBoxIconHelper.GetName(icon),
                                     String.IsNullOrEmpty(okScript) ? "''" : JsHelper.GetFunction(okScript)));
            }
        }
Exemple #3
0
        /// <summary>
        /// 获取字符串数组的脚本字符串形式
        /// </summary>
        /// <param name="values">字符串数组</param>
        /// <returns>字符串数组的脚本字符串</returns>
        public static string GetJsStringArray(string[] values)
        {
            StringBuilder sb = new StringBuilder();

            foreach (string value in values)
            {
                sb.AppendFormat("{0},", JsHelper.GetJsString(value));
            }
            return(String.Format("[{0}]", sb.ToString().TrimEnd(',')));
        }
Exemple #4
0
 /// <summary>
 /// 获取字段验证失败提示信息的客户端脚本
 /// </summary>
 /// <param name="message">提示信息</param>
 /// <returns>客户端脚本</returns>
 public string GetMarkInvalidReference(string message)
 {
     return(String.Format("{0}.markInvalid({1});", ScriptID, JsHelper.GetJsString(message)));
 }
Exemple #5
0
        /// <summary>
        /// 获取关闭当前激活窗体并回发父页面的客户端脚本
        /// </summary>
        /// <param name="argument">回发参数</param>
        /// <returns>客户端脚本</returns>
        public static string GetHidePostBackReference(string argument)
        {
            //return ACTIVE_WINDOW_SCRIPT + "if(aw){eval('aw[1].X.'+aw[0].id+'_hide_postback(\"" + argument + "\");');}";
            //return ACTIVE_WINDOW_SCRIPT + "if(aw){aw[0].box_hide_postback('" + argument + "');}";

            //return "(function(){var aw=X.wnd.getActiveWindow(); if(aw){ aw[0].box_hide_postback('" + argument + "'); }})();";
            return("(function(){var aw=X.wnd.getActiveWindow();if(aw){aw[0].box_hide_postback(" + JsHelper.GetJsString(argument) + ");}})();");
        }