闪客动漫天地
欢迎 游客 , 注册 | 登录 | 会员 | 界面 | 简洁版本 | 在线 | 帮助
闪客动漫天地论坛

发表新主题 回复该主题
本主题被查看1126次, 共1个帖子, 1页, 当前为第1页     选择页数: 1      跳转到第   上一主题   下一主题
标题: 续:本论坛重写TextBox的功能
注册会员
UID: 309683
来自:
精华: 0
积分: 54
帖子: 54
注册: 2007-6-18 15:03:00
状态: 离线
威望: 0.00
金钱: 12.00 元
只看楼主 2007-06-19 11:01
续:本论坛重写TextBox的功能
[Bindable(true), Category("Appearance"), DefaultValue("")]
        public string SetFocusButtonID
        {
            get
            {
                object o = ViewState[this.ClientID + "_SetFocusButtonID"];
                return (o == null) ? "" : o.ToString();
            }
            set
            {
                ViewState[this.ClientID + "_SetFocusButtonID"] = value;
                if (value != "")
                {
                    tb.Attributes.Add("onkeydown", "if(event.keyCode==13){document.getElementById('" + value + "').focus();}");
                }
            }
        }

        [Bindable(true), Category("Appearance"), DefaultValue("")]
        public override string ID
        {
            get
            {
                return tb.ID;
            }
            set
            {
                tb.ID = value;
            }
        }


        //调控件的最大长度属性
        [Bindable(true), Category("Appearance"), DefaultValue("")]
        public int MaxLength
        {
            get
            {
                object o = ViewState["TextBox_MaxLength"];
                if (o != null)
                {
                    int maxlength = Convert.ToInt32(o.ToString());
                    AddAttributes("maxlength", maxlength.ToString());
                    return maxlength;
                }
                else
                {
                    return -1;
                }
            }
            set
            {
                ViewState["TextBox_MaxLength"] = value;
                AddAttributes("maxlength", value.ToString());
            }
        }


        //调控件的TextMode属性
        [Bindable(false), Category("Behavior"), DefaultValue(""), TypeConverter(typeof(TextModeFieldTypeControlsConverter)), Description("要滚动的对象。")]
        public string TextMode  //要进行校验的表达式
        {
            get
            {
                return tb.TextMode.ToString();
            }
            set
            {
                if (value == "assword") tb.TextMode = TextBoxMode.Password;
                if (value == "MultiLine")
                {
                    tb.TextMode = TextBoxMode.MultiLine;
                    tb.Attributes.Add("onkeyup", "return isMaxLen(this)");
                }
                if (value == "SingleLine") tb.TextMode = TextBoxMode.SingleLine;
            }
        }

        [Bindable(false), Category("Behavior"), DefaultValue(""), TypeConverter(typeof(RequiredFieldTypeControlsConverter)), Description("要滚动的对象。")]
        public string RequiredFieldType  //要进行校验的表达式
        {
            get
            {
                object o = ViewState["RequiredFieldType"];
                return (o == null) ? "" : o.ToString();
            }
            set
            {
                ViewState["RequiredFieldType"] = value;
                SetValiateControls();
            }
        }



        [Bindable(false), Category("Behavior"), DefaultValue("可为空"), TypeConverter(typeof(CanBeNullControlsConverter)), Description("要滚动的对象。")]
        public string CanBeNull  //要表达式是否可以为空
        {
            get
            {
                object o = ViewState["CanBeNull"];
                return (o == null) ? "" : o.ToString();
            }
            set
            {
                ViewState["CanBeNull"] = value;
                SetValiateControls();
            }
        }


        //是否进行 ' 号替换
        [Bindable(true), Category("Appearance"), DefaultValue("")]
        public bool IsReplaceInvertedComma
        {
            get
            {
                object o = ViewState["IsReplaceInvertedComma"];
                if (o == null || o.ToString().Trim() == "")
                {
                    return true;
                }
                else
                {
                    return o.ToString().ToLower() == "true" ? true : false;
                }
            }
            set
            {
                ViewState["IsReplaceInvertedComma"] = value;
            }
        }



        [Bindable(true), Category("Appearance"), DefaultValue("")]
        public string ValidationExpression
        {
            get
            {
                object o = ViewState["ValidationExpression"];
                if (o == null || o.ToString().Trim() == "")
                {
                    return null;
                }
                else
                {
                    return o.ToString().ToLower();
                }
            }
            set
            {
                ViewState["ValidationExpression"] = value;
            }
        }

        [Bindable(true), Category("Appearance"), DefaultValue("")]
        public string Text
        {
            get
            {

                if (this.RequiredFieldType == "日期")
                {
                    try
                    {
                        return DateTime.Parse(tb.Text).ToString("yyyy-MM-dd");
                    }
                    catch
                    {
                        return "1900-1-1";
                    }
                }

                if (this.RequiredFieldType == "日期时间")
                {
                    try
                    {
                        return DateTime.Parse(tb.Text).ToString("yyyy-MM-dd HH:mm:ss");
                    }
                    catch
                    {
                        return "1900-1-1 00:00:00";
                    }
                }
                else
                {
                    return IsReplaceInvertedComma ? tb.Text.Replace("'", "''").Trim() : tb.Text;
                }
            }
            set
            {
                if (this.RequiredFieldType.IndexOf("日期") >= 0)
                {
                    try
                    {
                        tb.Text = DateTime.Parse(value).ToString("yyyy-MM-dd");
                    }
                    catch
                    {
                        tb.Text = "";
                    }
                }

                if (this.RequiredFieldType.IndexOf("日期时间") >= 0)
                {
                    try
                    {
                        tb.Text = DateTime.Parse(value).ToString("yyyy-MM-dd HH:mm:ss");
                    }
                    catch
                    {
                        tb.Text = "";
                    }
                }
                else
                {
                    tb.Text = value;
                }
            }

        }

        //调控件的高度属性
        [Bindable(false), Category("Appearance"), DefaultValue("")]
        override public Unit Height
        {
            get
            {
                return tb.Height;
            }
            set
            {
                tb.Height = value;
            }
        }
#1  
发表新主题 回复该主题
本主题被查看1126次, 共1个帖子, 1页, 当前为第1页     选择页数: 1      跳转到第







现在的时间是 2008-08-30 19:31:20
沪ICP备05003105号

版权所有 闪客俱乐部  
         Powered by Discuz!NT 1.0.6666    Copyright © 2001-2008 Comsenz Inc.
Processed in 0.192 seconds