예제 #1
0
        public override void RenderControl(HtmlTextWriter writer)
        {
            if (Visible)
            {
                if (this.Page != null)
                {
                    this.Page.VerifyRenderingInServerForm(this);
                }

                //输入框
                writer.AddAttribute(HtmlTextWriterAttribute.Id, base.ClientID);
                writer.AddAttribute(HtmlTextWriterAttribute.Name, base.UniqueID);
                writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "true");
                writer.AddAttribute(HtmlTextWriterAttribute.Type, "Text");
                writer.AddAttribute(HtmlTextWriterAttribute.Value, this._seletedDate == DateTime.MinValue ? "" : this._seletedDate.ToString("yyyy/MM/dd"));
                if (!this.Disabled)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, OnClientClick.Replace("#ClientID#", "this").Replace("#ImageClientID#", "document.getElementById('" + base.ClientID + "_Picker')"), false);
                    //string strclick = OnClientClick.Replace("#ClientID#", "this").Replace("#ImageClientID#", "document.getElementById('" + base.ClientID + "_Picker')");

                    if (!DesignMode)
                    {
                        string str4 = "";
                        if (base.HasAttributes)
                        {
                            str4 = base.Attributes["onchange"];
                            if (str4 != null)
                            {
                                str4 = ComFunc.EnsureEndWithSemiColon(str4);
                                base.Attributes.Remove("onchange");
                            }
                        }

                        EventHandler handler = (EventHandler)base.Events[EventTextChanged];
                        if (handler != null)
                        {
                            PostBackOptions options = new PostBackOptions(this, string.Empty);
                            if (this.CausesValidation)
                            {
                                options.PerformValidation = true;
                                options.ValidationGroup   = this.ValidationGroup;
                            }
                            if (Page.Form != null)
                            {
                                options.AutoPostBack = true;
                            }
                            str4 = ComFunc.MergeScript(str4, Page.ClientScript.GetPostBackEventReference(options, true));
                            writer.AddAttribute("onpropertychange", str4);
                        }
                    }
                }
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, this.TextWidth.ToString() + "px");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.TextHeight.ToString() + "px");

                writer.RenderBeginTag(HtmlTextWriterTag.Input);
                writer.RenderEndTag();
                //添加空格
                writer.Write(" ");
                //image
                writer.AddAttribute(HtmlTextWriterAttribute.Id, base.ClientID + "_Picker");
                writer.AddAttribute(HtmlTextWriterAttribute.Name, base.UniqueID + "$Picker");
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, OnClientClick.Replace("#ClientID#", "document.getElementById('" + base.ClientID + "')").Replace("#ImageClientID#", "document.getElementById('" + base.ClientID + "_Picker')"));

                if (DesignMode)
                {
                    //string directoryPath = ComFunc.GetProjectPathInDesignMode();
                    writer.AddAttribute(HtmlTextWriterAttribute.Src, ResolveClientUrl(this.ImgPath));
                }
                else
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Src, ResolveClientUrl(this.ImgPath));
                }

                if (this.Disabled)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "true");
                }

                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, this.ImgWidth.ToString() + "px");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.ImgHeight.ToString() + "px");

                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();
            }
        }