Пример #1
0
        protected override void Render(HtmlTextWriter writer)
        {
            WebControl div = new WebControl(HtmlTextWriterTag.Div);

            LayoutTemplate.InstantiateIn(div);

            Controls.Clear();
            Controls.Add(div);

            div.CopyBaseAttributes(this);
            div.CssClass = this.CssClass;
            div.RenderControl(writer);
        }
Пример #2
0
        /// <summary>
        /// Generates the target-specific inner markup for the Web control to which the control adapter is attached.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> containing methods to render the target-specific output.</param>
        protected override void RenderContents(HtmlTextWriter writer)
        {
            // make sure any special base attributes from the RadioButton get written
            WebControl control = new WebControl(HtmlTextWriterTag.Span);

            control.ID = this.Control.ClientID;
            control.CopyBaseAttributes(this.Control);
            control.RenderBeginTag(writer);

            // call ListControlAdaptor RenderContents
            base.RenderContents(writer);

            control.RenderEndTag(writer);
        }
Пример #3
0
        internal static void CopyBaseAttributesToInnerControl(WebControl control, WebControl child)
        {
            short  tabIndex  = control.TabIndex;
            string accessKey = control.AccessKey;

            try
            {
                control.AccessKey = string.Empty;
                control.TabIndex  = 0;
                child.CopyBaseAttributes(control);
            }
            finally
            {
                control.TabIndex  = tabIndex;
                control.AccessKey = accessKey;
            }
        }
Пример #4
0
        private void SetChildProperties()
        {
            EnsureChildControls();
            _logInLinkButton.Visible   = false;
            _logInImageButton.Visible  = false;
            _logOutLinkButton.Visible  = false;
            _logOutImageButton.Visible = false;
            WebControl control = null;

            if (LoggedIn)
            {
                string logoutImageUrl = LogoutImageUrl;
                if (logoutImageUrl.Length > 0)
                {
                    _logOutImageButton.AlternateText = LogoutText;
                    _logOutImageButton.ImageUrl      = logoutImageUrl;
                    control = _logOutImageButton;
                }
                else
                {
                    _logOutLinkButton.Text = LogoutText;
                    control = _logOutLinkButton;
                }
            }
            else
            {
                string loginImageUrl = LoginImageUrl;
                if (loginImageUrl.Length > 0)
                {
                    _logInImageButton.AlternateText = LoginText;
                    _logInImageButton.ImageUrl      = loginImageUrl;
                    control = _logInImageButton;
                }
                else
                {
                    _logInLinkButton.Text = LoginText;
                    control = _logInLinkButton;
                }
            }
            control.CopyBaseAttributes(this);
            control.ApplyStyle(base.ControlStyle);
            control.Visible = true;
        }
Пример #5
0
        internal static void CopyBaseAttributesToInnerControl(WebControl control, WebControl child)
        {
            short  tabIndex  = control.TabIndex;
            string accessKey = control.AccessKey;
            Unit   width     = control.Width;
            Unit   height    = control.Height;

            try
            {
                control.AccessKey = string.Empty;
                control.TabIndex  = 0;
                control.Width     = Unit.Empty;
                control.Height    = Unit.Empty;
                child.CopyBaseAttributes(control);
            }
            finally
            {
                control.TabIndex  = tabIndex;
                control.AccessKey = accessKey;
                control.Width     = width;
                control.Height    = height;
            }
        }
Пример #6
0
        /// <summary>
        /// Generates the target-specific inner markup for the Web control to which the control adapter is attached.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> containing methods to render the target-specific output.</param>
        protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
        {
            RadioButtonList rbl = Control as RadioButtonList;

            if (rbl != null)
            {
                PostBackOptions postBackOption = null;

                if (rbl.AutoPostBack)
                {
                    postBackOption = new PostBackOptions(rbl, string.Empty);
                    if (rbl.CausesValidation && this.Page.GetValidators(rbl.ValidationGroup).Count > 0)
                    {
                        postBackOption.PerformValidation = true;
                        postBackOption.ValidationGroup   = rbl.ValidationGroup;
                    }
                    if (this.Page.Form != null)
                    {
                        postBackOption.AutoPostBack = true;
                    }
                }

                WebControl control = new WebControl(HtmlTextWriterTag.Span);
                control.ID = rbl.ClientID;
                control.CopyBaseAttributes(rbl);
                control.RenderBeginTag(writer);

                int i = 0;
                foreach (ListItem li in rbl.Items)
                {
                    writer.WriteLine();

                    if (rbl.RepeatDirection == RepeatDirection.Vertical)
                    {
                        writer.AddAttribute("class", "radio");
                        writer.RenderBeginTag(HtmlTextWriterTag.Div);
                    }
                    else
                    {
                        writer.AddAttribute("class", "radio-inline");
                    }

                    writer.RenderBeginTag(HtmlTextWriterTag.Label);

                    string itemId = string.Format("{0}_{1}", rbl.ClientID, i++);
                    writer.AddAttribute("id", itemId);
                    writer.AddAttribute("type", "radio");
                    writer.AddAttribute("name", rbl.UniqueID);
                    writer.AddAttribute("value", li.Value);
                    if (li.Selected)
                    {
                        writer.AddAttribute("checked", "checked");
                    }

                    foreach (var attributeKey in li.Attributes.Keys)
                    {
                        var key = attributeKey as string;
                        writer.AddAttribute(key, li.Attributes[key]);
                    }

                    if (postBackOption != null)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(postBackOption, true));
                    }

                    writer.RenderBeginTag(HtmlTextWriterTag.Input);
                    writer.RenderEndTag();

                    writer.Write(li.Text);

                    writer.RenderEndTag();      // Label

                    if (rbl.RepeatDirection == RepeatDirection.Vertical)
                    {
                        writer.RenderEndTag();  // Div
                    }

                    if (rbl.Page != null)
                    {
                        rbl.Page.ClientScript.RegisterForEventValidation(rbl.UniqueID, li.Value);
                    }
                }

                control.RenderEndTag(writer);

                if (rbl.Page != null)
                {
                    rbl.Page.ClientScript.RegisterForEventValidation(rbl.UniqueID);
                }
            }
        }