Example #1
0
        //[Category(CategoryName.OPTIONS)]
        //[DefaultValue("")]
        //[Description("控件容器样式类")]
        //public string ContainerClassName
        //{
        //    get
        //    {
        //        object obj = BoxState["ExtendContainerClassName"];
        //        return obj == null ? "" : (string)obj;
        //    }
        //    set
        //    {
        //        BoxState["ExtendContainerClassName"] = value;
        //    }
        //}

        //[Browsable(false)]
        //[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        //[Description("extjs控件类型")]
        //public string Xtype
        //{
        //    get
        //    {
        //        object[] xtypeAttributes = GetType().GetCustomAttributes(typeof(XTypeAttribute), true);
        //        if (xtypeAttributes != null && xtypeAttributes.Length == 1)
        //        {
        //            return (xtypeAttributes[0] as XTypeAttribute).Name;
        //        }

        //        return String.Empty;
        //    }
        //}

        //public override string AccessKey
        //{
        //    get
        //    {
        //        return base.AccessKey;
        //    }
        //    set
        //    {
        //        base.AccessKey = value;
        //    }
        //}
        #endregion

        #endregion

        #region OnPreRender

        /// <summary>
        /// 渲染 HTML 之前调用(AJAX回发)
        /// </summary>
        protected override void OnAjaxPreRender()
        {
            base.OnAjaxPreRender();

            StringBuilder sb = new StringBuilder();

            if (PropertyModified("CssStyle"))
            {
                sb.AppendFormat("{0}.el.applyStyles({1});", XID, JsHelper.Enquote(CssStyle));
            }

            // 老的 CssClass 会在 X.state(x0,{"CssClass":"green"}) 时自动删除,并自动添加新的 CssClass。
            // 为什么不在这里先removeClass,再addClass?因为此时我们已经不知道之前的CssClass是什么了,这里取得的是已经修改过的。
            // 在X.util的setFState函数中处理的
            if (PropertyModified("CssClass"))
            {
                //sb.AppendFormat("{0}.el.addClass({1});", XID, JsHelper.Enquote(CssClass));
            }

            //if (PropertyModified("FormItemClass"))
            //{
            //    sb.AppendFormat("{0}.el.addClass({1});", XID, JsHelper.Enquote(FormItemClass));
            //}

            AddAjaxScript(sb);
        }
Example #2
0
 /// <summary>
 /// 添加属性
 /// </summary>
 /// <param name="propertyName">属性名</param>
 /// <param name="propertyValue">属性值</param>
 /// <param name="persistOriginal">是否保持原样</param>
 public void AddProperty(string propertyName, object propertyValue, bool persistOriginal)
 {
     if (persistOriginal)
     {
         _properties.Add(propertyName, propertyValue.ToString());
     }
     else
     {
         if (propertyValue is string)
         {
             _properties.Add(propertyName, JsHelper.Enquote(propertyValue.ToString()));
         }
         else if (propertyValue is bool)
         {
             _properties.Add(propertyName, propertyValue.ToString().ToLower());
         }
         else if (propertyValue is float || propertyValue is double)
         {
             _properties.Add(propertyName, JsHelper.NumberToString(propertyValue));
         }
         else
         {
             _properties.Add(propertyName, propertyValue.ToString());
         }
     }
 }
Example #3
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            #region options

            OB.AddProperty("checked", Checked);

            if (!String.IsNullOrEmpty(GroupName))
            {
                OB.AddProperty("group", GroupName);
            }

            #endregion

            #region AutoPostBack

            string checkScript = String.Empty;
            if (!String.IsNullOrEmpty(GroupName))
            {
                checkScript = "if(F.util.checkGroupLastTime('" + GroupName + "')){" + GetPostBackEventReference() + "}";
            }
            else
            {
                checkScript = GetPostBackEventReference();
            }

            OB.Listeners.AddProperty("checkchange", JsHelper.GetFunction(checkScript), true);

            #endregion

            string jsContent = String.Format("var {0}=Ext.create('Ext.menu.CheckItem',{1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
Example #4
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()));
        }
Example #5
0
        // aw = aw
        //private static readonly string ACTIVE_WINDOW_SCRIPT = "if(!aw){var aw=parent.window.X.window_default_group.getActive();}";
        //private static readonly string ACTIVE_WINDOW_SCRIPT = "var parentClientID=box_getParentClientIdFromUrl();if(parentClientID){var window2=parent.window;var aw=parent.window.Ext.getCmp(parentClientID);if(aw.box_property_frame_element_name){window2=parent.Ext.query('iframe[name='+aw.box_property_frame_element_name+']')[0].contentWindow;aw=eval('window2.X.'+aw.id);}}";
        //private static readonly string ACTIVE_WINDOW_SCRIPT = "var aw=F.wnd.getActiveWindow();";

        #endregion

        #region GetWriteBackValueReference


        /// <summary>
        /// 获取将values值写回控件的客户端脚本
        /// </summary>
        /// <param name="values">需要写回的字符串列表</param>
        /// <returns>客户端脚本</returns>
        public static string GetWriteBackValueReference(params string[] values)
        {
            #region old code

            //// 去除重复的 ACTIVE_WINDOW_SCRIPT
            //if (controlClientIds.Contains(ACTIVE_WINDOW_SCRIPT))
            //{
            //    controlClientIds = controlClientIds.Replace(ACTIVE_WINDOW_SCRIPT, "");
            //}

            //// 此时 controlClientId 是个字符串 或者是 是个字符串的数组,里面是需要赋值的文本框的ClientID
            //StringBuilder sb = new StringBuilder();
            //sb.Append(ACTIVE_WINDOW_SCRIPT);
            //sb.AppendFormat("var controlClientIds={0};", controlClientIds);

            //sb.AppendFormat("if(typeof(controlClientIds)=='string'){{{0}}}", "aw[1].Ext.getCmp(controlClientIds).setValue(" + JsHelper.Enquote(value) + ");");

            //// values
            //StringBuilder valuesBuilder = new StringBuilder();
            //if (values.Length > 0)
            //{
            //    valuesBuilder.AppendFormat("var controlValues={0};", JsHelper.GetJsStringArray(values));
            //    valuesBuilder.Append("var controlCount=Math.min(controlClientIds.length-1,controlValues.length);");

            //    valuesBuilder.AppendFormat("for(var i=0;i<controlCount;i++){{{0}}}", "aw[1].Ext.getCmp(controlClientIds[i+1]).setValue(controlValues[i]);");
            //}


            //sb.AppendFormat("else{{{0}{1}}}", "aw[1].Ext.getCmp(controlClientIds[0]).setValue(" + JsHelper.Enquote(value) + ");", valuesBuilder.ToString());
            //return sb.ToString();

            #endregion

            return(String.Format("F.wnd.writeBackValue.apply(window,{0});", JsHelper.GetJsStringArray(values)));
        }
Example #6
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            OB.AddProperty("checked", Checked);

            // In CheckBox control, Text is the showing beside the checkbox.
            if (!String.IsNullOrEmpty(Text))
            {
                OB.AddProperty("boxLabel", Text);
            }


            if (AutoPostBack)
            {
                // We should attach the "check" event after the control is rendered.
                // Because in the rendering process, the control will also trigger the "check" event, then we cann't distinguish it from the actual event.

                // We don't need delay here, because every PostBack has been delayed in global "ajaxPostBack" function.
                //string checkEventScript = String.Format("{0}.on('check',{1},X,{{delay:0}});", XID, JsHelper.GetFunction(GetPostBackEventReference()));
                //string renderScript = "(function(){" + checkEventScript + "}).defer(20);";

                //// 既然不需要延迟执行回发请求,那么就没必要放在render事件中了
                //string checkEventScript = String.Format("this.on('check',{0});", JsHelper.GetFunction(GetPostBackEventReference()));
                //OB.Listeners.AddProperty("render", "function(){" + checkEventScript + "}", true);

                OB.Listeners.AddProperty("check", JsHelper.GetFunction(GetPostBackEventReference()), true);
            }


            string jsContent = String.Format("var {0}=new Ext.form.Checkbox({1});", XID, OB.ToString());

            AddStartupScript(jsContent);
        }
Example #7
0
        /// <summary>
        /// 更新ASP.NET控件
        /// </summary>
        /// <param name="sb"></param>
        /// <param name="doc"></param>
        private void UpdateASPNETControls(StringBuilder sb, HtmlDocument doc)
        {
            if (PageManager.Instance.AjaxAspnetControls == null)
            {
                return;
            }
            foreach (string controlId in PageManager.Instance.AjaxAspnetControls)
            {
                string  controlClientID = controlId;
                Control control         = ControlUtil.FindControl(controlId);
                if (control != null)
                {
                    controlClientID = control.ClientID;
                }
                string updateHtml = JsHelper.Enquote(GetHtmlNodeOuterHTML(controlClientID, doc));
                if (updateHtml != null)
                {
                    sb.Append(String.Format("F.util.replace('{0}', {1});", controlClientID, updateHtml));

                    /*
                     * // 如果是Asp.net按钮或者ImageButton,需要重新注册点击时AJAX回发页面,而不是调用Button(type=submit)的默认行为
                     * if (control != null && (control is System.Web.UI.WebControls.Button
                     || control is System.Web.UI.WebControls.ImageButton))
                     ||{
                     || sb.Append(String.Format("F.util.makeAspnetSubmitButtonAjax('{0}');", control.ClientID));
                     ||}
                     * */
                }
            }
        }
Example #8
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            //ResourceManager.Instance.AddJavaScriptComponent("form");

            #region Options



            #endregion

            #region ResolveRows

            // 包含行的列脚本
            string rowScriptStr = String.Empty;
            // 行的集合
            string rowItemScriptStr = String.Empty;

            // 如果存在Rows集合
            if (Rows.Count > 0)
            {
                // rowScriptStr
                // rowItemScriptStr: [X.__Panel1_UpdatePanelConnector1_Panel7_Form5_row0,X.__Panel1_UpdatePanelConnector1_Panel7_Form5_row2]
                ResolveRows(ref rowScriptStr, ref rowItemScriptStr);

                // 添加Items
                OB.RemoveProperty("items");
                OB.AddProperty("items", rowItemScriptStr, true);
            }

            //rowScriptStr += "\r\n";


            #endregion

            //OptionBuilder defaultsOB = new OptionBuilder();
            //defaultsOB.Listeners.AddProperty("change", JsHelper.GetFunction("F.util.setPageStateChanged();"), true);
            //OB.AddProperty("defaults", defaultsOB);

            //OB.Listeners.AddProperty("change", JsHelper.GetFunction("F.util.setPageStateChanged();"), true);
            OB.Listeners.AddProperty("dirtychange", JsHelper.GetFunction("F.util.setPageStateChanged(dirty);", "form", "dirty"), true);

            //if (!String.IsNullOrEmpty(SubmitButton))
            //{
            //    Control control = ControlUtil.FindControl(SubmitButton);
            //    if (control != null && control is ControlBase)
            //    {
            //        OB.Listeners.AddProperty("render", JsHelper.GetFunction("F.util.formEnterKey(form,'" + control.ClientID + "');", "form"), true);
            //    }
            //}


            string formPanelScript = String.Format("var {0}=Ext.create('Ext.form.Panel',{1});", XID, OB.ToString());
            //AddStartupScript(this, rowScriptStr + formPanelScript);

            string jsContent = rowScriptStr + formPanelScript;
            AddStartupScript(jsContent);
        }
Example #9
0
        private string GetGridTpls(HtmlDocument doc, string controlId)
        {
            string tpls = GetHtmlNodeInnerHTML(controlId + "_tpls", doc);

            tpls = Regex.Replace(tpls, "\r?\n\\s*", "");

            // 删除生成HTML中的 "\r\n     "
            return(JsHelper.Enquote(tpls));
        }
Example #10
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            //ResourceManager.Instance.AddJavaScriptComponent("form");

            #region Options



            #endregion

            //OptionBuilder defaultsOB = new OptionBuilder();
            //defaultsOB.Listeners.AddProperty("click", JsHelper.GetFunction("alert('ss');F.util.setPageStateChanged();"), true);
            //OB.AddProperty("defaults", defaultsOB);

            OB.Listeners.AddProperty("dirtychange", JsHelper.GetFunction("F.util.setPageStateChanged(dirty);", "form", "dirty"), true);

            //if (!String.IsNullOrEmpty(SubmitButton))
            //{
            //    Control control = ControlUtil.FindControl(SubmitButton);
            //    if (control != null && control is ControlBase)
            //    {
            //        OB.Listeners.AddProperty("render", JsHelper.GetFunction("F.util.formEnterKey(form,'" + control.ClientID + "');", "form"), true);
            //    }
            //}

            /*
             * Ext.override(Ext.form.Panel, {
             *  listeners: {
             *      render: function () {
             *          Ext.create('Ext.util.KeyNav', this.el, {
             *              "enter": function (e) {
             *                  var el = Ext.Element.getActiveElement();
             *                  if (el.type != 'textarea') {
             *                      var b = Ext.DomQuery.select('div[id=' + this.getId() + ']');
             *                      var a = Ext.DomQuery.select('*[type=submit]', b[0]);
             *                      if (a[0]) {
             *                          a[0].click();
             *                      }
             *                  } else {
             *                      // The user is in a textarea in the form so this feature
             *                      // is diabled to allow for character returns
             *                      // in field data.
             *                  }
             *              },
             *              scope: this
             *          });
             *      }
             *  }
             * });
             */


            string jsContent = String.Format("var {0}=Ext.create('Ext.form.Panel',{1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
Example #11
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=F.wnd.getActiveWindow(); if(aw){ aw[0].box_hide_postback('" + argument + "'); }})();";
            //return "(function(){var aw=F.wnd.getActiveWindow();if(aw){aw.f_hide_postback(" + JsHelper.Enquote(argument) + ");}})();";
            return("F.activeWnd.hidePostBack(" + JsHelper.Enquote(argument) + ");");
        }
Example #12
0
        /// <summary>
        /// 获取字符串数组的脚本字符串形式
        /// </summary>
        /// <param name="values">字符串数组</param>
        /// <returns>字符串数组的脚本字符串</returns>
        public static string EnquoteStringArray(string[] values)
        {
            StringBuilder sb = new StringBuilder();

            foreach (string value in values)
            {
                sb.AppendFormat("{0},", JsHelper.Enquote(value));
            }
            return(String.Format("[{0}]", sb.ToString().TrimEnd(',')));
        }
Example #13
0
        /// <summary>
        /// 获取回发的客户端脚本(触发PageManager的CustomEvent事件)
        /// </summary>
        /// <param name="enableAjax">当前请求是否启用AJAX</param>
        /// <param name="eventArgument">事件参数</param>
        /// <param name="validateForms">是否在回发前验证表单(在PageManager上进行表单配置)</param>
        /// <param name="persistOriginal">保持eventArgument参数原样输出</param>
        /// <returns>客户端脚本</returns>
        public string GetCustomEventReference(bool enableAjax, string eventArgument, bool validateForms, bool persistOriginal)
        {
            string arg = eventArgument;

            if (!persistOriginal)
            {
                arg = JsHelper.Enquote(arg);
            }
            return(String.Format("F.f_customEvent({0},{1},{2});", enableAjax.ToString().ToLower(), arg, validateForms.ToString().ToLower()));
        }
Example #14
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            //// 日期选择器也需要菜单组件的支持
            //ResourceManager.Instance.AddJavaScriptComponent("menu");

            // extjs 的日期格式化字符串
            string extjsDateFormatString = ExtDateTimeConvertor.ConvertToExtDateFormat(DateFormatString);

            OB.AddProperty("format", extjsDateFormatString);

            if (EnableChineseAltFormats)
            {
                OB.AddProperty("altFormats", "Y-m-d|Y-n-j|Ymd|Ynj|y-m-d|y-n-j|ymd|ynj");
            }
            else if (AltFormats != null)
            {
                StringBuilder formats = new StringBuilder();
                foreach (string format in AltFormats)
                {
                    formats.Append(ExtDateTimeConvertor.ConvertToExtDateFormat(format));
                    formats.Append("|");
                }
                OB.AddProperty("altFormats", formats.ToString().TrimEnd('|'));
            }

            //// 当前选中的日期值,这个在父类中已经设置了
            //OB.RemoveProperty(OptionName.Value);
            //if (SelectedDate != null) OB.AddProperty(OptionName.Value, Text);

            if (MaxDate != null)
            {
                OB.AddProperty("maxValue", MaxDate.Value.ToString(DateFormatString));
            }
            if (MinDate != null)
            {
                OB.AddProperty("minValue", MinDate.Value.ToString(DateFormatString));
            }

            if (!EnableEdit)
            {
                OB.AddProperty("editable", false);
            }


            if (EnableDateSelectEvent)
            {
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(GetPostBackEventReference("Select")), true);
            }

            string jsContent = String.Format("var {0}=Ext.create('Ext.form.field.Date',{1});", XID, OB.ToString());

            AddStartupScript(jsContent);
        }
Example #15
0
        /// <summary>
        /// 渲染 HTML 之前调用(AJAX回发)
        /// </summary>
        protected override void OnAjaxPreRender()
        {
            base.OnAjaxPreRender();

            StringBuilder sb = new StringBuilder();

            if (PropertyModified("Text"))
            {
                sb.AppendFormat("{0}.setText({1});", XID, JsHelper.Enquote(Text));
            }

            AddAjaxScript(sb);
        }
Example #16
0
        /// <summary>
        /// 渲染 HTML 之前调用(AJAX回发)
        /// </summary>
        protected override void OnAjaxPreRender()
        {
            base.OnAjaxPreRender();

            StringBuilder sb = new StringBuilder();

            if (PropertyModified("ImageUrl", "ImageWidth", "ImageHeight", "ImageCssClass", "ImageCssStyle", "ImageAlt", "ToolTip", "ToolTipTitle", "ToolTipAutoHide", "Icon"))
            {
                sb.AppendFormat("{0}.setValue({1});", XID, JsHelper.Enquote(GetInnerHtml()));
            }

            AddAjaxScript(sb);
        }
Example #17
0
        /// <summary>
        /// 渲染 HTML 之前调用(AJAX回发)
        /// </summary>
        protected override void OnAjaxPreRender()
        {
            base.OnAjaxPreRender();

            StringBuilder sb = new StringBuilder();

            if (PropertyModified("NavigateUrl", "Target", "OnClientClick", "Text", "ToolTip", "ToolTipTitle", "ToolTipAutoHide", "Enabled"))
            {
                sb.AppendFormat("{0}.setValue({1});", XID, JsHelper.Enquote(GetInnerHtml()));
            }

            AddAjaxScript(sb);
        }
Example #18
0
        private string GetGridTpls(HtmlDocument doc, string controlId)
        {
            string html = String.Empty;
            string tpls = GetHtmlNodeInnerHTML(controlId + "_tpls", doc);

            if (!String.IsNullOrEmpty(tpls))
            {
                // 删除生成HTML中的 "\r\n     "
                html = Regex.Replace(tpls, "\r?\n\\s*", "");
            }

            return(JsHelper.Enquote(html));
        }
Example #19
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            if (AutoGrowHeight)
            {
                OB.AddProperty("grow", AutoGrowHeight);

                if (AutoGrowHeightMax.Value != 1000)
                {
                    OB.AddProperty("growMax", AutoGrowHeightMax.Value);
                }

                if (AutoGrowHeightMin.Value != 60)
                {
                    OB.AddProperty("growMin", AutoGrowHeightMin.Value);
                }

                if (HideScrollbars)
                {
                    OB.AddProperty("preventScrollbars", true);
                }
            }


            // 如果Text属性存在于XState中,则不要重复设置value属性,而是在render事件中使用XState的值
            if (XState.ModifiedProperties.Contains("Text"))
            {
                OB.RemoveProperty("value");
                OB.Listeners.AddProperty("render", JsHelper.GetFunction("cmp.x_setValue();", "cmp"), true);
            }


            //// 自动增长的最小高度要么等于高度,要么等于50(最小值)
            //if (AutoGrowHeight)
            //{
            //    Unit height = (Unit)50;
            //    if (Height != Unit.Empty)
            //    {
            //        height = Height;
            //    }

            //    OB.AddProperty("growMin", height.Value);
            //}

            string jsContent = String.Format("var {0}=new Ext.form.TextArea({1});", XID, OB.ToString());

            AddStartupScript(jsContent);
        }
Example #20
0
        /// <summary>
        /// 获取显示对话框的客户端脚本
        /// </summary>
        /// <returns>客户端脚本</returns>
        public string GetShowReference()
        {
            string message = "";
            string title   = "";

            if (!String.IsNullOrEmpty(Message))
            {
                message = Message;
            }
            if (!String.IsNullOrEmpty(Title))
            {
                title = Title;
            }


            JsObjectBuilder jsOB = new JsObjectBuilder();

            if (!String.IsNullOrEmpty(CancelScript))
            {
                jsOB.AddProperty("cancel", CancelScript);
            }

            if (!String.IsNullOrEmpty(OkScript))
            {
                jsOB.AddProperty("ok", OkScript);
            }

            if (Target != Target.Self)
            {
                jsOB.AddProperty("target", TargetHelper.GetName(Target));
            }

            if (MessageBoxIcon != MessageBoxIcon.Warning)
            {
                jsOB.AddProperty("messageIcon", MessageBoxIconHelper.GetShortName(MessageBoxIcon));
            }

            if (!String.IsNullOrEmpty(title))
            {
                jsOB.AddProperty("title", title.Replace("\r\n", "\n").Replace("\n", "<br/>"));
            }

            if (!String.IsNullOrEmpty(message))
            {
                jsOB.AddProperty("message", JsHelper.EnquoteWithScriptTag(message.Replace("\r\n", "\n").Replace("\n", "<br/>")), true);
            }

            return(String.Format("F.confirm({0});", jsOB.ToString()));
        }
Example #21
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            if (!String.IsNullOrEmpty(EmptyText))
            {
                OB.AddProperty("emptyText", EmptyText);
            }

            if (!String.IsNullOrEmpty(Text))
            {
                OB.AddProperty("value", Text);
            }

            if (AutoPostBack)
            {
                OB.Listeners.AddProperty("change", JsHelper.GetFunction(GetPostBackEventReference()), true);

                #region old code
                //// First remove change event, because we has already register this event in super class - Field.
                //OB.Listeners.RemoveProperty("change");

                //string changeScript = "F.util.setPageStateChanged();";
                //changeScript += GetPostBackEventReference();
                //OB.Listeners.AddProperty("change", JsHelper.GetFunction(changeScript), true);

                //else if (EnableServerValidate)
                //{
                //    // The Validate event will not be triggered when the filed fail to pass the client side validte.
                //    //changeScript += String.Format("if(X.{0}.isValid()){{{1}}}", ClientJavascriptID, GetPostBackEventReference("Validate"));
                //}
                //else if (AutoPostBack && EnableServerValidate)
                //{
                //    changeScript += GetPostBackEventReference("#VALIDATE#").Replace("'#VALIDATE#'", String.Format("{0}.isValid() ? 'Validate' : ''"));
                //}
                #endregion
            }

            if (EnableBlurEvent)
            {
                OB.Listeners.AddProperty("blur", JsHelper.GetFunction(GetPostBackEventReference("Blur")), true);
            }

            //if (EnableServerValidate)
            //{
            //    OB.Listeners.AddProperty("blur", JsHelper.GetFunctionWrapper(GetPostBackEventReference("Validate")), true);
            //}
        }
Example #22
0
        protected override void OnAjaxPreRender()
        {
            base.OnAjaxPreRender();

            StringBuilder sb = new StringBuilder();

            if (EnableIFrame)
            {
                if (PropertyModified("IFrameUrl"))
                {
                    sb.AppendFormat("X.wnd.updateIFrameNode({0},{1});", XID, JsHelper.Enquote(IFrameUrl));
                }
            }

            AddAjaxScript(sb);
        }
Example #23
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            #region options
            OB.AddProperty("checked", Checked);

            if (!String.IsNullOrEmpty(Text))
            {
                OB.AddProperty("boxLabel", Text);
            }

            if (!String.IsNullOrEmpty(GroupName))
            {
                OB.RemoveProperty("name");
                OB.AddProperty("name", GroupName);
                // <input type="radio" name="MyRadioGroup1" id="SimpleForm1_rbtnSecond" value="SimpleForm1_rbtnSecond">
                OB.AddProperty("inputValue", ClientID);
            }

            #endregion

            #region AutoPostBack

            //if (AutoPostBack)
            //{
            //    OB.Listeners.AddProperty("check", JsHelper.GetFunction(GetPostBackEventReference()), true);
            //}

            string checkScript = String.Empty;
            if (!String.IsNullOrEmpty(GroupName))
            {
                checkScript = "if(X.util.checkGroupLastTime('" + GroupName + "')){" + GetPostBackEventReference() + "}";
            }
            else
            {
                checkScript = GetPostBackEventReference();
            }

            OB.Listeners.AddProperty("check", JsHelper.GetFunction(checkScript), true);

            #endregion

            string jsContent = String.Format("var {0}=new Ext.form.Radio({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
Example #24
0
        /// <summary>
        /// 渲染 HTML 之前调用(AJAX回发)
        /// </summary>
        protected override void OnAjaxPreRender()
        {
            base.OnAjaxPreRender();

            StringBuilder sb = new StringBuilder();

            if (PropertyModified("Text"))
            {
                sb.AppendFormat("{0}.x_setText();", XID);
            }

            if (EnablePress)
            {
                if (PropertyModified("Pressed"))
                {
                    //if (ClientPropertyModifiedInServer("Pressed"))

                    sb.AppendFormat("{0}.x_toggle();", XID);
                }
            }

            if (PropertyModified("Icon", "IconUrl"))
            {
                string resolvedIconUrl = IconHelper.GetResolvedIconUrl(Icon, IconUrl);
                if (!String.IsNullOrEmpty(resolvedIconUrl))
                {
                    sb.AppendFormat("{0}.setIcon({1});", XID, JsHelper.Enquote(resolvedIconUrl));
                }
            }

            if (PropertyModified("ToolTip"))
            {
                sb.AppendFormat("{0}.x_setTooltip();", XID);
            }

            if (PropertyModified("OnClientClick", "ConfirmTitle", "ConfirmText", "ConfirmTarget", "ConfirmIcon"))
            {
                //sb.AppendFormat("{0}.un('click', {0}.initialConfig.listeners.click);", XID);
                //sb.AppendFormat("{0}.on('click',{1});", XID, GetClickScriptFunction());

                sb.AppendFormat("{0}.setHandler({1});", XID, JsHelper.GetFunction(GetClickScript()));
            }

            AddAjaxScript(sb);
        }
Example #25
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            #region options
            OB.AddProperty("checked", Checked);

            if (!String.IsNullOrEmpty(Text))
            {
                OB.AddProperty("boxLabel", Text);
            }

            if (!String.IsNullOrEmpty(GroupName))
            {
                OB.RemoveProperty("name");
                OB.AddProperty("name", GroupName);
                OB.AddProperty("inputValue", ClientID);
            }

            #endregion

            #region AutoPostBack

            if (AutoPostBack)
            {
                string checkScript = String.Empty;
                if (!String.IsNullOrEmpty(GroupName))
                {
                    checkScript = "if(F.util.checkGroupLastTime('" + GroupName + "')){" + GetPostBackEventReference() + "}";
                }
                else
                {
                    checkScript = GetPostBackEventReference();
                }

                OB.Listeners.AddProperty("change", JsHelper.GetFunction(checkScript), true);
            }

            #endregion

            string jsContent = String.Format("var {0}=Ext.create('Ext.form.field.Radio',{1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
Example #26
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            AddStartupAbsoluteScript("X.form_upload_file=true;");


            if (!String.IsNullOrEmpty(ButtonText))
            {
                OB.AddProperty("buttonText", ButtonText);
            }

            if (ButtonOnly)
            {
                OB.AddProperty("buttonOnly", true);
            }


            string resolvedIconUrl = IconHelper.GetResolvedIconUrl(ButtonIcon, ButtonIconUrl);

            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                OptionBuilder buttonOB = new OptionBuilder();
                buttonOB.AddProperty("cls", " x-btn-text-icon");
                buttonOB.AddProperty("icon", resolvedIconUrl);

                OB.AddProperty("buttonCfg", buttonOB);
            }
            //if (TextMode != TextMode.Text)
            //{
            //    OB.AddProperty("inputType", TextModeHelper.GetName(TextMode));
            //}

            if (AutoPostBack)
            {
                OB.Listeners.RemoveProperty("change");
                OB.Listeners.AddProperty("fileselected", JsHelper.GetFunction(GetPostBackEventReference()), true);
            }

            string jsContent = String.Format("var {0}=new Ext.ux.form.FileUploadField({1});", XID, OB.ToString());

            AddStartupScript(jsContent);
        }
Example #27
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            // extjs 的日期格式化字符串
            string extjsDateFormatString = ExtDateTimeConvertor.ConvertToExtDateFormat(DateFormatString);

            OB.AddProperty("format", extjsDateFormatString);

            //if (EnableChineseAltFormats)
            //{
            //    OB.AddProperty("altFormats", "Y-m-d|Y-n-j|Ymd|Ynj|y-m-d|y-n-j|ymd|ynj");
            //}

            if (SelectedDate != null)
            {
                OB.AddProperty("value", ExtDateTimeConvertor.GetExtDateObject(SelectedDate.Value), true);
            }

            if (MaxDate != null)
            {
                OB.AddProperty("maxDate", ExtDateTimeConvertor.GetExtDateObject(MaxDate.Value), true);
            }

            if (MinDate != null)
            {
                OB.AddProperty("minDate", ExtDateTimeConvertor.GetExtDateObject(MinDate.Value), true);
            }


            if (EnableDateSelectEvent)
            {
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(GetPostBackEventReference("Select")), true);
            }


            string jsContent = String.Format("var {0}=Ext.create('Ext.picker.Date',{1});", XID, OB.ToString());

            AddStartupScript(jsContent);
        }
Example #28
0
        /// <summary>
        /// 获取显示对话框的客户端脚本
        /// </summary>
        /// <returns>客户端脚本</returns>
        public string GetShowReference()
        {
            string message = "";
            string title   = "";

            if (!String.IsNullOrEmpty(Message))
            {
                message = Message;
            }
            if (!String.IsNullOrEmpty(Title))
            {
                title = Title;
            }

            JsObjectBuilder jsOB = new JsObjectBuilder();

            if (Target != Target.Self)
            {
                jsOB.AddProperty("target", TargetHelper.GetName(Target));
            }

            if (NotifyIcon != NotifyIcon.Info)
            {
                jsOB.AddProperty("notifyIcon", NotifyIconHelper.GetName(NotifyIcon));
            }

            if (!String.IsNullOrEmpty(title))
            {
                jsOB.AddProperty("title", title.Replace("\r\n", "\n").Replace("\n", "<br/>"));
            }

            if (!String.IsNullOrEmpty(message))
            {
                jsOB.AddProperty("message", JsHelper.EnquoteWithScriptTag(message.Replace("\r\n", "\n").Replace("\n", "<br/>")), true);
            }

            return(String.Format("F.notify({0});", jsOB.ToString()));
        }
Example #29
0
        /// <summary>
        /// 渲染 HTML 之前调用(AJAX回发)
        /// </summary>
        protected override void OnAjaxPreRender()
        {
            base.OnAjaxPreRender();

            StringBuilder sb = new StringBuilder();

            if (PropertyModified("Readonly"))
            {
                sb.AppendFormat("{0}.setReadOnly({1});", XID, Readonly.ToString().ToLower());
            }

            if (PropertyModified("Label"))
            {
                string newLabel = Label;
                if (ShowRedStar)
                {
                    newLabel += GetRedStarHtml();
                }
                //newLabel += LabelSeparator;
                sb.AppendFormat("{0}.f_setLabel({1});", XID, JsHelper.Enquote(newLabel));
            }

            AddAjaxScript(sb);
        }
Example #30
0
        /// <summary>
        /// 添加属性
        /// </summary>
        /// <param name="propertyName">属性名</param>
        /// <param name="propertyValue">属性值</param>
        /// <param name="persistOriginal">是否保持原样</param>
        public void AddProperty(string propertyName, object propertyValue, bool persistOriginal)
        {
            // 容错处理(如果 propertyValue 为空,则不添加)
            if (propertyValue == null)
            {
                return;
            }


            // 添加属性之前,要先删除之前已经添加的属性,否则会出粗
            RemoveProperty(propertyName);

            if (persistOriginal)
            {
                _properties.Add(propertyName, propertyValue.ToString());
            }
            else
            {
                if (propertyValue is string)
                {
                    _properties.Add(propertyName, JsHelper.Enquote(propertyValue.ToString()));
                }
                else if (propertyValue is bool)
                {
                    _properties.Add(propertyName, propertyValue.ToString().ToLower());
                }
                else if (propertyValue is float || propertyValue is double)
                {
                    _properties.Add(propertyName, JsHelper.NumberToString(propertyValue));
                }
                else
                {
                    _properties.Add(propertyName, propertyValue.ToString());
                }
            }
        }