示例#1
0
        private void AddAttributesToRenderForTypeImageButton(HtmlTextWriter writer)
        {
            Page page = Page;

            writer.AddAttribute(HtmlTextWriterAttribute.Type, "image");

            string          text1           = UniqueID;
            PostBackOptions postBackOptions = GetPostBackOptionsForTypeImageButton();

            if ((text1 != null) && ((postBackOptions == null) || (postBackOptions.TargetControl == this)))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Name, text1);
            }
            bool   isEnabled           = IsEnabled;
            string onClientClickScript = string.Empty;

            if (isEnabled)
            {
                onClientClickScript = Util.EnsureEndWithSemiColon(OnClientClick);
                if (HasAttributes)
                {
                    string text3 = Attributes["onclick"];
                    if (text3 != null)
                    {
                        onClientClickScript = onClientClickScript + Util.EnsureEndWithSemiColon(text3);
                        Attributes.Remove("onclick");
                    }
                }
            }
            if (Enabled && !isEnabled)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
            }
            base.AddAttributesToRender(writer);
            if ((page != null) && (postBackOptions != null))
            {
                page.ClientScript.RegisterForEventValidation(postBackOptions);
                if (isEnabled)
                {
                    string text4 = page.ClientScript.GetPostBackEventReference(postBackOptions, false);
                    if (!string.IsNullOrEmpty(text4))
                    {
                        onClientClickScript = Util.MergeScript(onClientClickScript, text4);
                    }
                }
            }
            if (onClientClickScript.Length > 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onClientClickScript);
                //if (base.EnableLegacyRendering)
                //{
                //    writer.AddAttribute("language", "javascript", false);
                //}
            }
            if (page != null)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Src,
                                    ControlHelper.GetFullImageUrl(ImageUrl, page));
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Src, ImageUrl);
            }
        }