コード例 #1
0
ファイル: Component.cs プロジェクト: jeason0813/ExtAspNet
        //[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

        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的setXState函数中处理的
            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);
        }
コード例 #2
0
ファイル: ResponseFilter.cs プロジェクト: xlfj5211/esb
        /// <summary>
        /// 更新ASP.NET控件
        /// </summary>
        /// <param name="writer"></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("X.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("X.util.makeAspnetSubmitButtonAjax('{0}');", control.ClientID));
                    }
                }
            }
        }
コード例 #3
0
ファイル: JsArrayBuilder.cs プロジェクト: xlfj5211/esb
 /// <summary>
 /// 添加属性
 /// </summary>
 /// <param name="propertyValue">属性值</param>
 /// <param name="persistOriginal">是否保持原样</param>
 public void AddProperty(object propertyValue, bool persistOriginal)
 {
     if (persistOriginal)
     {
         _properties.Add(propertyValue.ToString());
     }
     else
     {
         if (propertyValue is string)
         {
             _properties.Add(JsHelper.Enquote(propertyValue.ToString()));
         }
         else if (propertyValue is bool)
         {
             _properties.Add(propertyValue.ToString().ToLower());
         }
         else if (propertyValue is float || propertyValue is double)
         {
             _properties.Add(JsHelper.NumberToString(propertyValue));
         }
         else
         {
             _properties.Add(propertyValue.ToString());
         }
     }
 }
コード例 #4
0
ファイル: CheckBox.cs プロジェクト: xlfj5211/esb
        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);";

                string checkEventScript = String.Format("this.on('check',{0});", JsHelper.GetFunction(GetPostBackEventReference()));
                OB.Listeners.AddProperty("render", "function(){" + checkEventScript + "}", true);
            }


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

            AddStartupScript(jsContent);
        }
コード例 #5
0
ファイル: Confirm.cs プロジェクト: xlfj5211/esb
        /// <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()));
        }
コード例 #6
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=X.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("X.wnd.writeBackValue.apply(window,{0});", JsHelper.GetJsStringArray(values)));
        }
コード例 #7
0
ファイル: ResponseFilter.cs プロジェクト: xlfj5211/esb
        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));
        }
コード例 #8
0
ファイル: Alert.cs プロジェクト: jeason0813/ExtAspNet
        /// <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)));
            }
        }
コード例 #9
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(',')));
        }
コード例 #10
0
        protected override void OnAjaxPreRender()
        {
            base.OnAjaxPreRender();

            StringBuilder sb = new StringBuilder();

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

            AddAjaxScript(sb);
        }
コード例 #11
0
ファイル: Image.cs プロジェクト: xlfj5211/esb
        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);
        }
コード例 #12
0
ファイル: LinkButton.cs プロジェクト: jeason0813/ExtAspNet
        protected override void OnAjaxPreRender()
        {
            base.OnAjaxPreRender();

            StringBuilder sb = new StringBuilder();

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

            AddAjaxScript(sb);
        }
コード例 #13
0
ファイル: PanelBase.cs プロジェクト: xlfj5211/esb
        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);
        }
コード例 #14
0
        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 = GetResolvedIconUrl(this.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);
        }
コード例 #15
0
        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 = "X.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 (EnableServerValidate)
            //{
            //    OB.Listeners.AddProperty("blur", JsHelper.GetFunctionWrapper(GetPostBackEventReference("Validate")), true);
            //}
        }
コード例 #16
0
ファイル: Calendar.cs プロジェクト: xlfj5211/esb
        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 (EnableDateSelect)
            {
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(GetPostBackEventReference("Select")), true);
            }


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

            AddStartupScript(jsContent);
        }
コード例 #17
0
ファイル: DatePicker.cs プロジェクト: jeason0813/ExtAspNet
        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");
            }

            //// 当前选中的日期值,这个在父类中已经设置了
            //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 (EnableDateSelect)
            {
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(GetPostBackEventReference("Select")), true);
            }


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

            AddStartupScript(jsContent);
        }
コード例 #18
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            //ResourceManager.Instance.AddJavaScriptComponent("button");
            //if (Menu.Items.Count > 0)
            //{
            //    ResourceManager.Instance.AddJavaScriptComponent("menu");
            //}

            #region Properties
            if (TabIndex != null)
            {
                OB.AddProperty("tabIndex", TabIndex);
            }

            if (!String.IsNullOrEmpty(ToolTip))
            {
                OB.AddProperty("tooltip", ToolTip);
                OB.AddProperty("tooltipType", ToolTipTypeName.GetName(ToolTipType));
            }

            OB.AddProperty("text", Text);

            if (EnablePress)
            {
                OB.AddProperty("enableToggle", EnablePress);
                OB.AddProperty("pressed", Pressed);

                //hiddenFieldsScript += GetSetHiddenFieldValueScript(PressedHiddenFieldID, Pressed.ToString().ToLower());
                //string toggleScript = String.Format("function(btn,pressed){{X.util.setHiddenFieldValue('{0}',pressed);}}", PressedHiddenFieldID);
                //OB.Listeners.AddProperty(OptionName.Toggle, toggleScript, true);
            }

            if (Type != ButtonType.Button)
            {
                OB.AddProperty("type", ButtonTypeName.GetName(Type));
            }

            if (Size != ButtonSize.Small)
            {
                OB.AddProperty("scale", ButtonSizeName.GetName(Size));
            }

            #endregion

            #region Icon IconUrl

            string resolvedIconUrl = GetResolvedIconUrl(Icon, IconUrl);
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                // 不需要先删除原来的属性,因为在AddProperty内部已经有这个逻辑了
                OB.AddProperty("cls", CssClass + " x-btn-text-icon");
                OB.AddProperty("icon", resolvedIconUrl);

                if (IconAlign != IconAlign.Left)
                {
                    OB.AddProperty("iconAlign", IconAlignHelper.GetName(IconAlign));
                }
            }

            #endregion

            #region Click

            string clickScript = GetClickScript();
            if (!String.IsNullOrEmpty(clickScript))
            {
                OB.AddProperty("handler", JsHelper.GetFunction(clickScript), true);
            }

            #endregion

            #region oldcode

            //string clickScriptFunction = GetClickScriptFunction();
            //if (AjaxPropertyChanged("ClickScriptFunction", clickScriptFunction))
            //{
            //    string ajaxClickFunction = String.Empty;
            //    //ajaxClickFunction += String.Format("{0}.purgeListeners('click');", ClientJavascriptID);
            //    ajaxClickFunction += String.Format("{0}.un('click', X.{0}.initialConfig.listeners.click);", XID);
            //    ajaxClickFunction += String.Format("{0}.on('click',{1});", XID, clickScriptFunction);

            //    AddAjaxPropertyChangedScript(ajaxClickFunction);
            //}

            //OB.Listeners.AddProperty(OptionName.Click, String.Format("{0}_click", ClientJavascriptID), true);


            //OB.AddProperty(OptionName.Handler, "function(){alert('sss');}", true);



            //string style = String.Empty;

            //if (CssStyle == "" || !CssStyle.ToLower().Contains("display"))
            //{
            //    style += CssStyle + "display:inline;";
            //}

            //OB.RemoveProperty(OptionName.Style);
            //OB.AddProperty(OptionName.Style, style);

            //AddExtraStyle("display", "inline");

            #endregion

            #region Menu

            /*
             * if (Menus.Count > 0)
             * {
             *  // 一个Button只能由一个Menu
             *  OB.AddProperty("menu", String.Format("{0}", Menus[0].XID), true);
             * }
             * */
            if (Menu.Items.Count > 0)
            {
                OB.AddProperty("menu", String.Format("{0}", Menu.XID), true);
            }

            #endregion

            string createScript = String.Format("var {0}=new Ext.Button({1});", XID, OB.ToString());
            AddStartupScript(createScript);
        }
コード例 #19
0
ファイル: RadioButtonList.cs プロジェクト: xlfj5211/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            #region options

            if (Required)
            {
                OB.AddProperty("allowBlank", false);
                if (!String.IsNullOrEmpty(RequiredMessage))
                {
                    OB.AddProperty("blankText", RequiredMessage);
                }
            }


            OB.RemoveProperty("name");

            if (ColumnNumber <= 0)
            {
                OB.AddProperty("columns", "auto");
            }
            else
            {
                OB.AddProperty("columns", ColumnNumber);
            }

            if (ColumnVertical)
            {
                OB.AddProperty("vertical", true);
            }

            #endregion

            #region Items

            string xstateName  = String.Format("{0}_xstate", XID);
            string xitemsName  = String.Format("{0}_xitems", XID);
            string hasDataName = xstateName;

            string xstate = OB.GetProperty("x_state");
            OB.AddProperty("x_state", xstateName, true);

            string jsState = String.Format("var {0}={1};", xstateName, xstate);

            if (!XState.ModifiedProperties.Contains("X_Items"))
            {
                xstate = ConvertPropertiesToJObject(new List <string> {
                    "X_Items", "SelectedValue"
                }).ToString(Formatting.None);
                jsState    += String.Format("var {0}={1};", xitemsName, xstate);
                hasDataName = xitemsName;
            }

            //if (Items.Count > 0)
            //{
            //    //OB.AddProperty("items", GetItemsJArray().ToString(Formatting.None), true);
            //    OB.AddProperty("items", String.Format("X.util.resolveCheckBoxGroup('{0}',{1})", UniqueID, hasDataName), true);
            //}
            OB.AddProperty("items", String.Format("X.util.resolveCheckBoxGroup('{0}',{1})", UniqueID, hasDataName), true);


            if (Items.Count == 0)
            {
                OB.Listeners.AddProperty("afterrender", JsHelper.GetFunction("cmp.x_toBeDeleted();", "cmp"), true);
            }

            #endregion

            #region AutoPostBack

            if (AutoPostBack)
            {
                // This event will be triggered twice, so we must filter the actually change.
                // If the current checked radio is losing focus, this function will alse be called and the radio parameter is true.
                // 改变选中项时,这个事件会被触发两次。
                // 当前选中项失去焦点时,这个回调函数也会被触发并设置radio为true。
                OB.Listeners.AddProperty("change", String.Format("function(group,radio){{if(typeof(radio)!=='boolean'){{{0}}}}}", GetPostBackEventReference()), true);
            }

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

            #region old code
            //string autoPostBackScript = String.Empty;
            //if (AutoPostBack)
            //{
            //    //// change 事件只有在失去焦点时才触发,是不及时的
            //    //OB.Listeners.RemoveProperty(OptionName.Change);
            //    //OB.Listeners.AddProperty(OptionName.Check, String.Format("function(newValue,oldValue){{\r\nbox_pageStateChange();alert(newValue+':'+oldValue);\r\n}}"), true);

            //    string selectScript = String.Format("function(newValue,oldValue){{\r\nalert(newValue+':'+oldValue);\r\n}}");
            //    selectScript = String.Format("{0}.on('{1}',{2},box,{{delay:0}});", ClientID, OptionName.Check, selectScript);

            //    autoPostBackScript += selectScript;
            //}

            //string backgroundColorStyle = String.Empty;
            //if (EnableBackgroundColor)
            //{
            //    backgroundColorStyle = AboutConfig.GetDefaultBackgroundColor(PageManagerInstance.Theme.ToString());
            //}
            //else if (EnableLightBackgroundColor)
            //{
            //    backgroundColorStyle = AboutConfig.GetLightBackgroundColor(PageManagerInstance.Theme.ToString());
            //}

            //if (!String.IsNullOrEmpty(backgroundColorStyle))
            //{
            //    string backgroundColorScript = String.Format("Ext.each(X.{0}.el.query('.x-panel-body'),function(item,index){{Ext.get(item).setStyle('background-color','{1}');}});", ClientJavascriptID, backgroundColorStyle);

            //    string renderScript = "(function(){" + backgroundColorScript + "}).defer(20);";
            //    OB.Listeners.AddProperty("render", "function(component){" + renderScript + "}", true);
            //}

            #endregion

            #endregion

            string jsContent = String.Format("var {0}=new Ext.form.RadioGroup({1});", XID, OB.ToString());
            AddStartupScript(jsState + jsContent);
        }
コード例 #20
0
        internal override string GetColumnValue(GridRow row)
        {
            //string result = String.Empty;

            #region DataTextField

            string text = String.Empty;

            if (!String.IsNullOrEmpty(DataTextField))
            {
                object value = row.GetPropertyValue(DataTextField);

                if (!String.IsNullOrEmpty(DataTextFormatString))
                {
                    text = String.Format(DataTextFormatString, value);
                    if (HtmlEncodeFormatString)
                    {
                        text = HttpUtility.HtmlEncode(text);
                    }
                }
                else
                {
                    text = value.ToString();
                    if (HtmlEncode)
                    {
                        text = HttpUtility.HtmlEncode(text);
                    }
                }
            }
            else
            {
                text = Text;
            }

            #endregion

            HtmlNodeBuilder nb;

            #region Enabled

            nb = new HtmlNodeBuilder("a");

            if (Enabled)
            {
                nb.SetProperty("href", "javascript:;");

                // click
                string paramStr          = String.Format("Command${0}${1}${2}${3}", row.RowIndex, ColumnIndex, CommandName.Replace("'", "\""), CommandArgument.Replace("'", "\""));
                string postBackReference = Grid.GetPostBackEventReference(paramStr);

                string clientScript = Button.ResolveClientScript(ValidateForms, ValidateTarget, ValidateMessageBox, EnablePostBack, postBackReference,
                                                                 ConfirmText, ConfirmTitle, ConfirmIcon, ConfirmTarget, OnClientClick, String.Empty);

                clientScript = JsHelper.GetDeferScript(clientScript, 0) + "X.util.stopEventPropagation.apply(null, arguments);";

                nb.SetProperty("onclick", clientScript);

                //result = nb.ToString();
            }
            else
            {
                nb.SetProperty("class", "x-item-disabled");
                nb.SetProperty("disabled", "disabled");

                //nb = new HtmlNodeBuilder("span");
                //nb.SetProperty("class", "gray");
                //nb.InnerProperty = text;
                //result = String.Format("<span class=\"gray\">{0}</span>", text);
            }

            nb.InnerProperty = text;

            #endregion

            string tooltip = GetTooltipString(row);

            #region Icon IconUrl

            string resolvedIconUrl = IconHelper.GetResolvedIconUrl(Icon, IconUrl);
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                nb.InnerProperty = String.Format("<img src=\"{0}\" {1} />", resolvedIconUrl, tooltip) + nb.InnerProperty;
            }

            #endregion

            //string result = nb.ToString();
            //#region Tooltip

            //if (!String.IsNullOrEmpty(tooltip))
            //{
            //    if (result.StartsWith("<a "))
            //    {
            //        result = result.ToString().Insert(2, tooltip);
            //    }
            //    else if (result.StartsWith("<span "))
            //    {
            //        result = result.ToString().Insert(5, tooltip);
            //    }
            //}

            //#endregion

            //return result;

            string result = nb.ToString();

            if (!String.IsNullOrEmpty(tooltip))
            {
                result = result.ToString().Insert("<a".Length, tooltip);
            }

            return(result);
        }
コード例 #21
0
ファイル: SimpleForm.cs プロジェクト: xlfj5211/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            ResourceManager.Instance.AddJavaScriptComponent("form");

            #region Options

            //JsObjectBuilder fieldDefaults = new JsObjectBuilder();
            if (LabelWidth.Value != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT)
            {
                OB.AddProperty("labelWidth", LabelWidth.Value);
            }
            if (LabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT)
            {
                OB.AddProperty("labelSeparator", LabelSeparator);
            }

            if (LabelAlign != LabelAlign.Left)
            {
                OB.AddProperty("labelAlign", LabelAlignHelper.GetName(LabelAlign));
            }

            //if (fieldDefaults.Count > 0)
            //{
            //    OB.AddProperty("fieldDefaults", fieldDefaults);
            //}

            #region old code

            //// 如果存在Fields集合
            //if (Fields.Count > 0)
            //{
            //    JsArrayBuilder ab = new JsArrayBuilder();
            //    foreach (Field item in Fields)
            //    {
            //        ab.AddProperty(String.Format("{0}", item.ClientID), true);
            //    }
            //    OB.AddProperty(OptionName.Items, ab.ToString(), true);
            //}

            #endregion

            #endregion

            #region Anchor

            //JsObjectBuilder defaults = new JsObjectBuilder();

            //if (OffsetRight.Value != ConfigPropertyValue.FORM_OFFSETRIGHT_DEFAULT)
            //{
            //    defaults.AddProperty("anchor", -OffsetRight.Value);
            //}
            //else if (PageManager.Instance.FormOffsetRight.Value != ConfigPropertyValue.FORM_OFFSETRIGHT_DEFAULT)
            //{
            //    defaults.AddProperty("anchor", -PageManager.Instance.FormOffsetRight.Value);
            //}
            //else
            //{
            //    defaults.AddProperty("anchor", "auto");
            //}

            //OB.AddProperty("defaults", defaults);

            #endregion


            OB.Listeners.AddProperty("change", JsHelper.GetFunction("X.util.setPageStateChanged();"), true); //this.doLayout();

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


            #region old code

            //string doLayoutScript = String.Empty;

            //doLayoutScript += "\r\n";
            //if (Visible)
            //{
            //    doLayoutScript += String.Format("Ext.EventManager.onWindowResize(function(){{X.{0}.doLayout();}},box);", ClientJavascriptID);
            //}
            //AddAbsoluteStartupScript(doLayoutScript);

            #endregion
        }
コード例 #22
0
ファイル: TabStrip.cs プロジェクト: jeason0813/ExtAspNet
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            ResourceManager.Instance.AddJavaScriptComponent("tab");

            if (EnableTabCloseMenu)
            {
                ResourceManager.Instance.AddJavaScriptComponent("menu");
            }

            #region Tabs

            if (Tabs.Count > 0)
            {
                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (Tab tab in Tabs)
                {
                    if (tab.Visible)
                    {
                        ab.AddProperty(String.Format("{0}", tab.XID), true);
                    }
                }
                OB.AddProperty("items", ab.ToString(), true);
            }

            #endregion

            #region options

            // 删除Layout配置参数
            OB.RemoveProperty("layout");

            //OB.AddProperty(OptionName.TabMargin, TabMargin.Value);
            OB.AddProperty("tabPosition", TabPositionHelper.GetName(TabPosition));
            //if (Plain) OB.AddProperty(OptionName.Plain, Plain);
            if (!EnableTitleBackgroundColor)
            {
                OB.AddProperty("plain", true);
            }


            // 去掉deferredRender=true,渲染速度会提高200ms左右
            // 每个Tab是否只在第一次访问时渲染,false表示全部渲染,否则没有访问的Tab的内容渲染的位置不正确。
            OB.AddProperty("deferredRender", EnableDeferredRender);

            //OB.AddProperty("bufferResize", true);

            // 在切换Tab时重新布局Tab的内容
            OB.AddProperty("layoutOnTabChange", true);

            OB.AddProperty("enableTabScroll", true);

            if (EnableTabCloseMenu)
            {
                OB.AddProperty("plugins", "new Ext.ux.TabCloseMenu()", true);
            }

            ////Note: By default, a tab's close tool destroys the child tab Component and all its descendants.
            //// This makes the child tab Component, and all its descendants unusable.
            //// To enable re-use of a tab, configure the TabPanel with autoDestroy: false.
            //OB.AddProperty("autoDestroy", false);

            #endregion

            #region ActiveTabIndex/IFrameDelayLoad

            OB.AddProperty("activeTab", ActiveTabIndex);

            //for (int i = 0; i < Tabs.Count; i++)
            //{
            //    Tab tab = Tabs[i];
            //    if (tab.EnableIFrame && i != ActiveTabIndex)
            //    {
            //        // 拥有IFrame的Tab如果不是激活Tab,则不设置Url,只有在激活时才设置Url
            //        tab.IFrameDelayLoad = true;
            //    }
            //    else
            //    {
            //        tab.IFrameDelayLoad = false;
            //    }
            //}

            #endregion

            #region Listeners

            #region old code

            // 如果存在Tabs集合
            //if (Tabs.Count > 0)
            //{
            //    JsArrayBuilder ab = new JsArrayBuilder();
            //    foreach (Tab tab in Tabs)
            //    {
            //        ab.AddProperty(String.Format("{0}", tab.ClientID), true);
            //    }
            //    OB.AddProperty(OptionName.Items, ab.ToString(), true);
            //}

            // listeners
            //JsObjectBuilder listenersBuilder = new JsObjectBuilder();
            //listenersBuilder.AddProperty(OptionName.Tabchange, String.Format("function(tabPanel, activeTab){{Ext.get('{0}').dom.value=tabPanel.items.indexOf(activeTab);}}", ActiveTabHiddenField.ClientID), true);
            //OBuilder.AddProperty("listeners", listenersBuilder.ToString(), true);

            #endregion

            // 如果要激活的Tab含有IFrame,则需要加载IFrame
            // 改变Tab需要回发的脚本
            // Make sure X_AutoPostBackTabs property exist in X_STATE during page's first load.
            //string tabchangeScript2 = String.Format("if(tabPanel.x_autoPostBackTabsContains(tab.id)){{{0}}}", GetPostBackEventReference());

            string tabchangeScript = "X.wnd.updateIFrameNode(tab);";
            string postbackScript  = String.Empty;
            if (AutoPostBack)
            {
                tabchangeScript += "if(!tab.x_dynamic_added_tab){" + GetPostBackEventReference() + "}";
            }

            // 如果是动态添加的Tab,不做任何处理(在js/box/extender.js中)
            //string tabchangeScript = "X.wnd.updateIFrameNode(tab);if(!tab.x_dynamic_added_tab){" + postbackScript + "}";
            OB.Listeners.AddProperty("tabchange", JsHelper.GetFunction(tabchangeScript, "tabPanel", "tab"), true);

            #endregion

            #region old code

            //// 添加隐藏字段
            //string needPostBackTabIDsScript = GetNeedPostBackTabIDsScript();
            //hiddenFieldsScript += needPostBackTabIDsScript;

            //if (AjaxPropertyChanged("NeedPostBackTabIdsScript", needPostBackTabIDsScript))
            //{
            //    AddAjaxPropertyChangedScript(needPostBackTabIDsScript);
            //}


            //hiddenFieldsScript += GetSetHiddenFieldValueScript(ActiveTabHiddenFieldID, ActiveTabIndex.ToString().ToLower());

            #endregion

            #region old code

            //// An bug in IE.
            //string renderScript = "if(Ext.isIE){(function(){this.getActiveTab().removeClass('x-hide-display');}).defer(20,this);}";

            //OB.Listeners.AddProperty("render", JsHelper.GetFunction(renderScript), true);

            #endregion

            string jsContent = String.Format("var {0}=new Ext.TabPanel({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
コード例 #23
0
ファイル: TriggerBox.cs プロジェクト: xlfj5211/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();



            #region options
            if (!ShowTrigger)
            {
                OB.AddProperty("hideTrigger", true);
            }

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



            #endregion

            #region TriggerIcon

            if (TriggerIcon != TriggerIcon.None)
            {
                OB.AddProperty("triggerClass", TriggerIconHelper.GetName(TriggerIcon));
            }
            else if (!String.IsNullOrEmpty(TriggerIconUrl))
            {
                string className = String.Format("extaspnet_{0}_triggerbox_icon", XID);
                string selector  = String.Format(".x-form-field-wrap .{0}", className);
                AddStartupCSS(className, StyleUtil.GetBackgroundStyle(selector, ResolveUrl(TriggerIconUrl)));

                OB.AddProperty("triggerClass", className);
            }


            #endregion

            #region TriggerClick

            if (Enabled)
            {
                string clientClickScript = OnClientTriggerClick;
                if (!String.IsNullOrEmpty(clientClickScript) && !clientClickScript.EndsWith(";"))
                {
                    clientClickScript += ";";
                }

                string postbackScript = String.Empty;
                if (EnablePostBack)
                {
                    postbackScript = GetPostBackEventReference();
                }

                OB.AddProperty("onTriggerClick", JsHelper.GetFunction(clientClickScript + postbackScript), true);
            }

            #endregion

            #region Specialkey

            if (Enabled)
            {
                // 首先启用enableKeyEvents
                //OB.AddProperty("enableKeyEvents", true);
                OB.Listeners.AddProperty("specialkey", String.Format("function(field,e){{if(e.getKey()==e.ENTER){{{0}.onTriggerClick();e.stopEvent();}}}}", XID), true);

                //OB.Listeners.AddProperty("keydown", JsHelper.GetFunction("var i=0;"), true);
            }

            #endregion

            #region old code

            //// 只禁用文本框,不禁用Trigger
            //if (Readonly)
            //{
            //    //OB.AddProperty(OptionName.Disabled, true);
            //    //AddAbsoluteStartupScript( String.Format("{0}.el.dom.disabled=true;", ClientID));



            //    //OB.Listeners.AddProperty(OptionName.Focus, String.Format("function(field){{field.blur.defer(10,field);\r\n}}"), true);
            //    //OB.Listeners.AddProperty(OptionName.Keydown, String.Format("function(){{return false;}}"), true);


            //    // 晕,最后的解决方案居然是设置 readonly=true
            //    OB.AddProperty(OptionName.ReadOnly, true);

            //    //string cssClassName = CssClass;
            //    //cssClassName += "x-item-disabled";

            //    //OB.RemoveProperty(OptionName.Cls);
            //    //OB.AddProperty(OptionName.Cls, cssClassName);
            //    //OB.AddProperty(OptionName.FocusClass, "");
            //}

            #endregion

            string jsContent = String.Format("var {0}=new Ext.form.TriggerField({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
コード例 #24
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            #region options

            if (!ShowTrigger)
            {
                OB.AddProperty("hideTrigger", true);
            }


            if (!ShowTrigger1)
            {
                OB.AddProperty("hideTrigger1", true);
            }
            if (!ShowTrigger2)
            {
                OB.AddProperty("hideTrigger2", true);
            }

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

            #endregion

            #region Trigger1Icon/Trigger2Icon

            if (Trigger1Icon != TriggerIcon.None)
            {
                OB.AddProperty("trigger1Class", TriggerIconHelper.GetName(Trigger1Icon));
            }
            else if (!String.IsNullOrEmpty(Trigger1IconUrl))
            {
                string className = String.Format("extaspnet_{0}_twintriggerbox_icon1", XID);
                string selector  = String.Format(".x-form-field-wrap .x-form-twin-triggers .{0}", className);
                AddStartupCSS(className, StyleUtil.GetBackgroundStyle(selector, ResolveUrl(Trigger1IconUrl)));

                OB.AddProperty("trigger1Class", className);
            }


            if (Trigger2Icon != TriggerIcon.None)
            {
                OB.AddProperty("trigger2Class", TriggerIconHelper.GetName(Trigger2Icon));
            }
            else if (!String.IsNullOrEmpty(Trigger2IconUrl))
            {
                string className = String.Format("extaspnet_{0}_twintriggerbox_icon2", XID);
                string selector  = String.Format(".x-form-field-wrap .x-form-twin-triggers .{0}", className);
                AddStartupCSS(className, StyleUtil.GetBackgroundStyle(selector, ResolveUrl(Trigger2IconUrl)));

                OB.AddProperty("trigger2Class", className);
            }


            #endregion

            #region Trigger1Click/Trigger1Click

            if (Enabled)
            {
                string clientTrigger1ClickScript = OnClientTrigger1Click;
                if (!String.IsNullOrEmpty(clientTrigger1ClickScript) && !clientTrigger1ClickScript.EndsWith(";"))
                {
                    clientTrigger1ClickScript += ";";
                }
                string trigger1PostbackScript = String.Empty;
                if (EnableTrigger1PostBack)
                {
                    trigger1PostbackScript = GetPostBackEventReference("Trigger$1");
                }
                //string trigger1ClickScript = String.Format("function(){{{0}}}", clientTrigger1ClickScript + trigger1PostbackScript);
                //// createDelegate 用来为一个Function创建一个Scope
                //OB.AddProperty(OptionName.OnTrigger1Click, String.Format("({0}).createDelegate(box)", trigger1ClickScript), true);
                OB.AddProperty("onTrigger1Click", JsHelper.GetFunction(clientTrigger1ClickScript + trigger1PostbackScript), true);


                string clientTrigger2ClickScript = OnClientTrigger2Click;
                if (!String.IsNullOrEmpty(clientTrigger2ClickScript) && !clientTrigger2ClickScript.EndsWith(";"))
                {
                    clientTrigger2ClickScript += ";";
                }
                string trigger2PostbackScript = String.Empty;
                if (EnableTrigger2PostBack)
                {
                    trigger2PostbackScript = GetPostBackEventReference("Trigger$2");
                }
                //string trigger2ClickScript = String.Format("function(){{{0}}}", clientTrigger2ClickScript + Trigger2PostbackScript);
                //// createDelegate 用来为一个Function创建一个Scope
                //OB.AddProperty(OptionName.OnTrigger2Click, String.Format("({0}).createDelegate(box)", trigger2ClickScript), true);
                OB.AddProperty("onTrigger2Click", JsHelper.GetFunction(clientTrigger2ClickScript + trigger2PostbackScript), true);
            }

            #endregion

            #region Specialkey

            if (Enabled)
            {
                // 首先启用enableKeyEvents
                //OB.AddProperty("enableKeyEvents", true);
                OB.Listeners.AddProperty("specialkey", String.Format("function(field,e){{if(e.getKey()==e.ENTER){{{0}.onTrigger2Click();e.stopEvent();}}}}", XID), true);
            }

            #endregion

            #region old code

            //string renderScript = String.Empty;


            ////// 只禁用文本框,不禁用Trigger
            ////if (!EnableTextBox)
            ////{
            ////    //AddAbsoluteStartupScript(String.Format("{0}.el.dom.disabled=true;", ClientJavascriptID));
            ////    renderScript += String.Format("{0}.el.dom.disabled=true;", ClientJavascriptID);
            ////}


            //if (AjaxPropertyChanged("ShowTrigger1", ShowTrigger1))
            //{
            //    AddAjaxPropertyChangedScript(String.Format("{0}.getTrigger(0).{1}();", XID, ShowTrigger1 ? "show" : "hide"));
            //}

            //if (AjaxPropertyChanged("ShowTrigger2", ShowTrigger2))
            //{
            //    AddAjaxPropertyChangedScript(String.Format("{0}.getTrigger(1).{1}();", XID, ShowTrigger2 ? "show" : "hide"));
            //}


            //renderScript = "(function(){" + renderScript + "}).defer(20);";
            //OB.Listeners.AddProperty("render", "function(component){" + renderScript + "}", true);

            #endregion

            string jsContent = String.Format("var {0}=new Ext.form.TwinTriggerField({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
コード例 #25
0
ファイル: CheckBoxField.cs プロジェクト: xlfj5211/esb
        /// <summary>
        /// 取得单元格的数据
        /// </summary>
        /// <param name="row"></param>
        /// <param name="checkState"></param>
        /// <returns></returns>
        private string GetColumnValue(GridRow row, bool checkState)
        {
            string result = String.Empty;

            if (!String.IsNullOrEmpty(DataField))
            {
                string textAlignClass = String.Empty;
                if (TextAlign != TextAlign.Left)
                {
                    textAlignClass = "box-grid-checkbox-" + TextAlignName.GetName(TextAlign);
                }

                if (RenderAsStaticField)
                {
                    if (checkState)
                    {
                        result = "<div class=\"box-grid-static-checkbox " + textAlignClass + "\"></div>";
                    }
                    else
                    {
                        result = "<div class=\"box-grid-static-checkbox box-grid-static-checkbox-unchecked " + textAlignClass + "\"></div>";
                    }
                }
                else
                {
                    string paramStr = String.Format("Command${0}${1}${2}${3}", row.RowIndex, ColumnIndex, CommandName.Replace("'", "\""), CommandArgument.Replace("'", "\""));
                    // 延迟执行
                    string postBackReference = JsHelper.GetDeferScript(Grid.GetPostBackEventReference(paramStr), 0);

                    // string onClickScript = String.Format("{0}_checkbox{1}(event,this,{2});", Grid.XID, ColumnIndex, row.RowIndex);
                    string onClickScript = "Ext.get(this).toggleClass('box-grid-checkbox-unchecked');";
                    if (AutoPostBack)
                    {
                        onClickScript += postBackReference;
                    }

                    onClickScript += "X.util.stopEventPropagation.apply(null, arguments);";

                    if (checkState)
                    {
                        if (Enabled)
                        {
                            result = String.Format("<div class=\"box-grid-checkbox {0}\" onclick=\"{1}\"></div>", textAlignClass, onClickScript);
                        }
                        else
                        {
                            result = String.Format("<div class=\"box-grid-checkbox box-grid-checkbox-disabled {0}\"></div>", textAlignClass);
                        }
                    }
                    else
                    {
                        if (Enabled)
                        {
                            result = String.Format("<div class=\"box-grid-checkbox box-grid-checkbox-unchecked {0}\" onclick=\"{1}\"></div>", textAlignClass, onClickScript);
                        }
                        else
                        {
                            result = String.Format("<div class=\"box-grid-checkbox box-grid-checkbox-disabled box-grid-checkbox-unchecked-disabled {0}\"></div>", textAlignClass);
                        }
                    }
                }
            }

            return(result);
        }
コード例 #26
0
ファイル: DropDownList.cs プロジェクト: jeason0813/ExtAspNet
        protected override void OnFirstPreRender()
        {
            // 确保 X_Items 和 SelectedValue 在页面第一次加载时都存在于x_state中
            XState.AddModifiedProperty("X_Items");
            XState.AddModifiedProperty("SelectedValue");

            base.OnFirstPreRender();

            #region examples

            //var nextStepList = [
            //    ['审核', '1'],
            //    ['不审核', '2']
            //];
            //var nextStepStore = new Ext.data.SimpleStore({
            //    fields: ['text', 'value'],
            //    data: nextStepList
            //});
            //{
            //    xtype:'combo',
            //    store: nextStepStore,
            //    displayField:'text',
            //    valueField:'value',
            //    typeAhead: true,
            //    mode: 'local',
            //    triggerAction: 'all',
            //    value:'1',
            //    emptyText:'请选择下一步',
            //    selectOnFocus:true,
            //    allowBlank:false,
            //    fieldLabel: '下一步',
            //    labelSeparator:'&nbsp;<span style="color:red;vertical-align:text-bottom;">*</span>',
            //    name: 'nextStep',
            //    anchor:'95%'
            //}

            #endregion

            #region Properties

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

            if (!ForceSelection)
            {
                OB.AddProperty("forceSelection", false);
            }

            if (Resizable)
            {
                OB.AddProperty("resizable", true);
            }

            OB.AddProperty("hiddenName", UniqueID);
            //OB.RemoveProperty("name");
            OB.AddProperty("store", "new Ext.data.ArrayStore({fields:['value','text','enabled','prefix']})", true);


            #region old code
            //OB.AddProperty("mode", "local");
            //// 点击下拉按钮时显示全部内容
            //OB.AddProperty("triggerAction", "all");
            //// 必须选中一个值,不能自己输入内容
            //OB.AddProperty("forceSelection", true);
            //// 此下拉列表控件不可以编辑
            //OB.AddProperty("editable", false);

            //OB.AddProperty(OptionName.Title, "Title");
            //if (TypeAhead) OB.AddProperty(OptionName.TypeAhead, true);
            //OB.AddProperty(OptionName.SelectOnFocus, true);

            //// SelectedValue可以为空
            //if (!String.IsNullOrEmpty(SelectedValue))
            //{
            //    OB.AddProperty("value", SelectedValue);
            //}
            #endregion

            #endregion

            #region old code

            //string hiddenFieldsScript = String.Empty;
            //if (AutoPostBack)
            //{
            //    hiddenFieldsScript += GetSetHiddenFieldValueScript(LastSelectedValueHiddenID, SelectedValue);
            //}

            //string disableSelectRowIndexsString = GetDisableSelectRowIndexsString();
            //string disableSelectRowIndexsScript = GetSetHiddenFieldValueScript(DisableRowIndexsHiddenID, disableSelectRowIndexsString);

            //// TODO:
            //// 这个要放在加载数据的前面,因为加载数据时需要渲染UI,渲染UI时需要用到这个隐藏字段的值
            //if (AjaxPropertyChanged("DisableSelectRowIndexsString", disableSelectRowIndexsString))
            //{
            //    AddAjaxPropertyChangedScript(disableSelectRowIndexsScript);
            //}


            // 不管是不是disableSelectFields.Count > 0,都要执行下面的语句,因为可能页面加载时为0,在Ajax后不为零
            //if (disableSelectFields.Count > 0)
            //OB.AddProperty(OptionName.Tpl, String.Format("'<tpl for=\".\"><div class=\"x-combo-list-item {{[X.util.isHiddenFieldContains(\"{0}\",xindex-1) ? \"box-combo-list-item-disable-select\" : \"\"]}}\">{{text}}</div></tpl>'", DisableSelectRowIndexsHiddenID), true);
            //var tplStr = "'<tpl for=\".\"><div class=\"x-combo-list-item\">{text}</div></tpl>'";
            //var tplStr = "new Ext.XTemplate('<tpl for=\".\"><div class=\"x-combo-list-item\">{text}</div></tpl>')";

            //var tplStr = "<tpl for=\".\"><div class=\"x-combo-list-item <tpl if=\"!enabled\">x-combo-list-item-disable</tpl>\">{prefix}{text}</div></tpl>";
            //OB.AddProperty("tpl", tplStr);
            //OB.AddProperty("tpl", tplStr.Replace("#DisableRowIndexsHiddenID#", DisableRowIndexsHiddenID), true);


            //string setSimulateTreeTextFunctionScript = String.Empty;
            //string setSimulateTreeTextScript = String.Empty;
            //if (EnableSimulateTree)
            //{
            //    string setSimulateTextScript = String.Format("var text=Ext.get('{0}').dom.value;if(text.lastIndexOf('<img')>=0){{Ext.get('{0}').dom.value=X.util.stripHtmlTags(text);}}", ClientID);
            //    setSimulateTreeTextFunctionScript = String.Format("{0}_setSimulateText=function(){{{1}}};", ClientJavascriptID, setSimulateTextScript);

            //    // 加载完毕后,显示选中的值
            //    //AddAbsoluteStartupScript(String.Format("{0}_setSimulateText();", ClientJavascriptID));
            //    // 下拉列表加载完毕后,立即去掉前面图片的HTML标签
            //    string renderScript = JsHelper.GetDeferScript(String.Format("{0}_setSimulateText();", ClientJavascriptID), 20); // "(function(){" + String.Format("{0}_setSimulateText();", ClientJavascriptID) + "}).defer(20);";
            //    OB.Listeners.AddProperty(OptionName.EVENT_RENDER, "function(component){" + renderScript + "}", true);
            //}


            //string simulateTreeAllScript = String.Empty;
            //if (EnableSimulateTree)
            //{
            //    // 在选中一项后,立即去掉前面图片的HTML标签
            //    simulateTreeAllScript += "\r\n";
            //    //string simulateTreeScript = String.Format("function(ddl,record,index){{var text=record.data.text;var startDivIndex=text.lastIndexOf('</div>');text=text.substr(startDivIndex+6);Ext.get('{0}').dom.value=text;}}", ClientID);
            //    string simulateTreeScript = String.Format("function(ddl,record,index){{X.{0}_setSimulateText();}}", ClientJavascriptID);
            //    simulateTreeScript = String.Format("{0}.on('{1}',{2},box,{{delay:0}});", ClientJavascriptID, OptionName.Select, simulateTreeScript);
            //    //AddAbsoluteStartupScript( simulateTreeScript);
            //    simulateTreeAllScript += simulateTreeScript;

            //    simulateTreeAllScript += "\r\n";
            //    string simulateTreeBlurScript = String.Format("function(ddl){{X.{0}_setSimulateText();}}", ClientJavascriptID);
            //    simulateTreeBlurScript = String.Format("{0}.on('{1}',{2},box,{{delay:10}});", ClientJavascriptID, OptionName.Blur, simulateTreeBlurScript);
            //    //AddAbsoluteStartupScript( simulateTreeBlurScript);
            //    simulateTreeAllScript += simulateTreeBlurScript;
            //}



            // These are default values, which are assignment in extender.js.
            //OB.AddProperty("displayField", "text");
            //OB.AddProperty("valueField", "value");
            //OB.AddProperty("store", "new Ext.data.ArrayStore({fields:['value','text','enabled','prefix']})", true);

            //string dataScript = String.Empty;
            //string fields = "['value','text','enabled','prefix']";
            //string storeScript = "new Ext.data.ArrayStore({fields:['value','text','enabled','prefix']})";//", fields, GetDataArrayString()); // GetDataArrayString()

            //OB.AddProperty(OptionName.Store, String.Format("new Ext.data.ArrayStore({{fields:['value','text'],data:{0}}})", dataArrayString), true);
            //OB.AddProperty("store", String.Format("{0}_data", XID), true);
            //string dataScript = String.Format("{0}_data=new Ext.data.ArrayStore({{fields:['value','text'],data:{1}}});", ClientJavascriptID, dataArrayString);
            //sb.AppendFormat("this.{0}_store=new Ext.data.SimpleStore({{fields:['text', 'value'],data:this.{0}_data}});", ClientJavascriptID);
            #endregion

            #region AutoPostBack

            StringBuilder beforeselectSB = new StringBuilder();
            // 是否能选中一项(如果此项不能选中,则点击没用)
            //beforeselectSB.AppendFormat("if(X.util.isHiddenFieldContains('{0}',index)){{return false;}}", DisableRowIndexsHiddenID);
            beforeselectSB.Append("if(!record.data.enabled){return false;}");

            if (AutoPostBack)
            {
                beforeselectSB.Append("cmp.x_tmp_lastvalue=cmp.getValue();");

                string selectScript = "if(cmp.x_tmp_lastvalue!==cmp.getValue()){" + GetPostBackEventReference() + "}";
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(selectScript, "cmp"), true);
            }

            OB.Listeners.AddProperty("beforeselect", JsHelper.GetFunction(beforeselectSB.ToString(), "cmp", "record", "index"), true);

            #region old code
            //if (AutoPostBack)
            //{
            //    // Note: we can't use change event, because it get triggered when the combox lost focus, which is not in time.
            //    // Beforeselect - If current select item is not changed, don't PostBack.
            //    string beforeselectScript = String.Format("function(ddl,record,index){{Ext.get('{0}').dom.value=Ext.get('{1}').dom.value;}}", LastSelectedValueHiddenID, SelectedValueHiddenID);
            //    beforeselectScript = String.Format("{0}.on('{1}',{2},X,{{delay:0}});", XID, "beforeselect", beforeselectScript);
            //    //AddAbsoluteStartupScript( beforeselectScript);
            //    autoPostBackScript += beforeselectScript;

            //    // Select
            //    string selectScript = String.Format("function(ddl,record,index){{if(record.data.value!=Ext.get('{0}').dom.value){{{1}}}}}", LastSelectedValueHiddenID, GetPostBackEventReference());
            //    selectScript = String.Format("{0}.on('{1}',{2},X,{{delay:0}});", XID, "select", selectScript);
            //    //AddAbsoluteStartupScript( selectScript);
            //    autoPostBackScript += selectScript;


            //    //OB.Listeners.RemoveProperty(OptionName.Change);
            //    //OB.Listeners.AddProperty(OptionName.Change, String.Format("function(ddl,newValue,oldValue){{box_pageStateChange();alert(newValue+':'+oldValue);}}"), true);
            //}
            #endregion

            #endregion

            #region Listeners - render

            string renderScript = "cmp.x_loadData();cmp.x_setValue();";

            OB.Listeners.AddProperty("render", JsHelper.GetFunction(renderScript, "cmp"), true);

            #endregion

            #region AddStartupScript

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

            AddStartupScript(contentScript);

            #region old code
            //List<string> totalModifiedProperties = XState.GetTotalModifiedProperties();
            //StringBuilder loadDataSB = new StringBuilder();
            //if (totalModifiedProperties.Contains("X_Items"))
            //{
            //    loadDataSB.AppendFormat("{0}.x_loadData();", XID);
            //}
            //else
            //{
            //    loadDataSB.AppendFormat("{0}.store.loadData({1});", XID, X_Items.ToString());
            //}

            //if (totalModifiedProperties.Contains("SelectedValue"))
            //{
            //    loadDataSB.AppendFormat("{0}.x_setValue();", XID);
            //}
            //else
            //{
            //    loadDataSB.AppendFormat("{0}.x_setValue({1});", XID, JsHelper.Enquote(SelectedValue));
            //}
            #endregion

            #endregion
        }
コード例 #27
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            ResourceManager.Instance.AddJavaScriptComponent("form");

            #region Options

            //JsObjectBuilder fieldDefaults = new JsObjectBuilder();
            //if (LabelWidth.Value != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT)
            //{
            //    fieldDefaults.AddProperty("labelWidth", LabelWidth.Value);
            //}
            //if (LabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT)
            //{
            //    fieldDefaults.AddProperty("labelSeparator", LabelSeparator);
            //}

            //if (fieldDefaults.Count > 0)
            //{
            //    OB.AddProperty("fieldDefaults", fieldDefaults);
            //}

            if (LabelWidth.Value != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT)
            {
                OB.AddProperty("labelWidth", LabelWidth.Value);
            }
            if (LabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT)
            {
                OB.AddProperty("labelSeparator", LabelSeparator);
            }

            if (LabelAlign != LabelAlign.Left)
            {
                OB.AddProperty("labelAlign", LabelAlignHelper.GetName(LabelAlign));
            }

            #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

            // This bug has been fixed in extjs v3.4.0.
            // Do layout when body size changed - I don't know why extjs do it automatically.
            // Why panel.layout.layout? Because Form outside layout doesn't has this function, why? I don't know now.
            //OB.Listeners.AddProperty("bodyresize", "function(panel){if(panel.layout.layout){panel.doLayout();}}", true);

            OB.Listeners.AddProperty("change", JsHelper.GetFunction("X.util.setPageStateChanged();"), true);


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

            string jsContent = rowScriptStr + formPanelScript;
            AddStartupScript(jsContent);

            #region oldcode

            //string doLayoutScript = String.Empty;

            //doLayoutScript += String.Format("Ext.EventManager.onWindowResize(function(){{X.{0}.doLayout();}});", ClientJavascriptID);

            //AddPageFirstLoadAbsoluteScript(doLayoutScript);

            #endregion
        }
コード例 #28
0
ファイル: TextField.cs プロジェクト: xlfj5211/esb
 /// <summary>
 /// 获取字段验证失败提示信息的客户端脚本
 /// </summary>
 /// <param name="message">提示信息</param>
 /// <returns>客户端脚本</returns>
 public string GetMarkInvalidReference(string message)
 {
     return(String.Format("{0}.markInvalid({1});", ScriptID, JsHelper.GetJsString(message)));
 }
コード例 #29
0
ファイル: TextField.cs プロジェクト: xlfj5211/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            #region validate properties

            if (Required)
            {
                OB.AddProperty("allowBlank", false);
                if (!String.IsNullOrEmpty(RequiredMessage))
                {
                    OB.AddProperty("blankText", RequiredMessage);
                }
            }

            if (MaxLength != null)
            {
                OB.AddProperty("maxLength", MaxLength.Value);
                if (!String.IsNullOrEmpty(MaxLengthMessage))
                {
                    OB.AddProperty("maxLengthText", MaxLengthMessage);
                }
            }
            if (MinLength != null)
            {
                OB.AddProperty("minLength", MinLength.Value);
                if (!String.IsNullOrEmpty(MinLengthMessage))
                {
                    OB.AddProperty("minLengthText", MinLengthMessage);
                }
            }

            // Calculate regex expression via RegexPattern and Regex
            string regexStr = String.Empty;
            if (RegexPattern != RegexPattern.None)
            {
                regexStr = RegexPatternHelper.GetRegexValue(RegexPattern);
            }
            else if (!String.IsNullOrEmpty(Regex))
            {
                regexStr = Regex;
            }

            if (!String.IsNullOrEmpty(regexStr))
            {
                OB.AddProperty("regex", String.Format("new RegExp({0})", JsHelper.Enquote(regexStr)), true);
                if (!String.IsNullOrEmpty(RegexMessage))
                {
                    OB.AddProperty("regexText", RegexMessage);
                }
            }

            #endregion

            #region NextFocusControl

            if (!String.IsNullOrEmpty(NextFocusControl))
            {
                Control nextControl = ControlUtil.FindControl(Page, NextFocusControl);

                if (nextControl != null && nextControl is ControlBase)
                {
                    //// true to enable the proxying of key events for the HTML input field (defaults to false)
                    //OB.AddProperty("enableKeyEvents", true);
                    // Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed.
                    OB.Listeners.AddProperty("specialkey", String.Format("function(field,e){{if(e.getKey()==e.ENTER){{{0}.focus(true,10);e.stopEvent();}}}}", (nextControl as ControlBase).XID), true);
                }
            }

            #endregion

            #region ControlToCompare

            string compareValue = String.Empty;
            // If CompareControl and CompareValue both exist, then CompareControl has higher priority.
            if (!String.IsNullOrEmpty(CompareControl))
            {
                Control compareControl = ControlUtil.FindControl(Page, CompareControl);
                if (compareControl != null && compareControl is ControlBase)
                {
                    compareValue = String.Format("X.util.getFormFieldValue(Ext.getCmp({0}))", JsHelper.Enquote((compareControl as ControlBase).ClientID));
                }
            }
            else if (!String.IsNullOrEmpty(CompareValue))
            {
                compareValue = CompareValue;
                if (CompareType == CompareType.String)
                {
                    compareValue = JsHelper.Enquote(compareValue);
                }
            }

            // Check whether compareValue exist, which may produced from CompareControl or CompareValue.
            if (!String.IsNullOrEmpty(compareValue))
            {
                string compareOperatorJs       = OperatorHelper.GetName(CompareOperator);
                string compareExpressionScript = String.Empty;
                if (CompareType == CompareType.String)
                {
                    compareExpressionScript = String.Format("value{0}{1}", compareOperatorJs, compareValue);
                }
                else if (CompareType == CompareType.Int)
                {
                    compareExpressionScript = String.Format("parseInt(value,10){0}parseInt({1},10)", compareOperatorJs, compareValue);
                }
                else if (CompareType == CompareType.Float)
                {
                    compareExpressionScript = String.Format("parseFloat(value){0}parseFloat({1})", compareOperatorJs, compareValue);
                }
                //else if (CompareType == CompareType.Date)
                //{
                //    compareExpressionScript = String.Format("Date.parse(value){0}Date.parse({1})", compareOperatorJs, compareValueJs);
                //}

                string compareScript = String.Format("if({0}){{return true;}}else{{return {1};}}", compareExpressionScript, JsHelper.Enquote(CompareMessage));
                OB.AddProperty("validator", String.Format("function(value){{if(this.getXType()==='combo'){{value=this.getValue();}}{0}}}", compareScript), true);
            }

            #endregion
        }
コード例 #30
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) + ");}})();");
        }