Ejemplo n.º 1
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            using (var w = new HtmlTextWriterWithAttributeFilter(writer)) {
                Page.VerifyRenderingInServerForm(this);

                w.AddAttribute(HtmlTextWriterAttribute.Type, "radio");
                w.AddAttribute(HtmlTextWriterAttribute.Name, UniqueGroupName);
                if (Checked)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Checked, ((OSPage)Page).QuirksMode ? null : "checked");
                }

                bool old_Enabled = Enabled;
                if (!Enabled)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Disabled, ((OSPage)Page).QuirksMode ? null : "disabled");
                    Enabled = true;
                }

                // dump ajax onchange handler
                AjaxEventsHelper.AddAjaxEventAttribute(this, AjaxEventType.onAjaxChange, ClientID, UniqueID, "__OSVSTATE", ViewStateAttributes.InlineAttributes);

                base.AddAttributesToRender(w);
                ViewStateAttributes.InlineAttributes.AddAttributes(w);
                Enabled = old_Enabled;
            }
        }
 protected override void AddAttributesToRender(HtmlTextWriter writer)
 {
     // add all attributes, excluding the id attribute
     using (var w = new HtmlTextWriterWithAttributeFilter(writer, new[] { "id" })) {
         base.AddAttributesToRender(w);
     }
 }
        /// <summary>
        /// This is exactly the same as in System.Web.UI.WebControls.Button, only the javascript
        /// of the onclick attribute is diferent.
        /// This change was done to support FireFox (#37171)
        /// </summary>
        /// <param name="writer"></param>
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            using (var w = new HtmlTextWriterWithAttributeFilter(writer)) {
                string onClickText = JavaScriptManager.GetButtonOnClickCode(ClientID, UniqueID, ViewStateAttributes.InlineAttributes["onclick"],
                                                                            _confirmMessage, (events != null) && events.Contains(AjaxEventType.onAjaxClick), CausesValidation);

                if (!string.IsNullOrEmpty(_navigateURL))
                {
                    onClickText += "window.location.href='" + _navigateURL + "'; return false;";
                }

                if (onClickText.Length > 0)
                {
                    ViewStateAttributes.InlineAttributes["onclick"] = onClickText;
                }

                bool old_Enabled = Enabled;
                if (!Enabled)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Disabled, ((OSPage)Page).QuirksMode ? null : "disabled");
                    Enabled = true;
                }

                ViewStateAttributes.InlineAttributes.AddAttributes(w);
                base.AddAttributesToRender(w);
                Enabled = old_Enabled;
            }
        }
Ejemplo n.º 4
0
        //public override bool SupportsDisabledAttribute { get { return true; } }

        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            using (var w = new HtmlTextWriterWithAttributeFilter(writer)) {
                // add to class='' the Valid style
                if (!this._valid)
                {
                    string cssClass = this.CssClass;
                    if (cssClass != null && cssClass != "")
                    {
                        this.CssClass = this.CssClass + " Not_Valid";
                    }
                    else
                    {
                        this.CssClass = "Not_Valid";
                    }
                }

                // TODO JMR #585790 uncommend SupportsDisabledAttribute override and delete this block when targetting .net 4.0+
                bool old_Enabled = Enabled;
                if (!Enabled)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Disabled, ((OSPage)Page).QuirksMode ? null : "disabled");
                    Enabled = true;
                }

                // dump ajax onchange handler
                AjaxEventsHelper.AddAjaxEventAttribute(this, AjaxEventType.onAjaxChange, ClientID, UniqueID, "__OSVSTATE", ViewStateAttributes.InlineAttributes);
                base.AddAttributesToRender(w);
                ViewStateAttributes.InlineAttributes.AddAttributes(w);
                Enabled = old_Enabled;
            }
        }
Ejemplo n.º 5
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            Utils.RemoveIdIfAnonymous(this, Attributes);

            if (BorderWidth.IsEmpty)
            {
                // base.AddAttributesToRender forces border-width style attribute.
                // Here we want to explicitly ignore it
                string[] exclude = new string[] { HtmlTextWriterAttribute.Border.ToString(), HtmlTextWriterStyle.BorderWidth.ToString() };
                using (HtmlTextWriter w = new HtmlTextWriterWithAttributeFilter(writer, exclude)) {
                    base.AddAttributesToRender(w);
                }
            }
            else
            {
                string border = BorderWidth.Value.ToString();
                BorderWidth = Unit.Empty;

                if (Attributes["border"] != null)
                {
                    border = Attributes["border"].ToString();
                    Attributes.Remove("border");
                }
                BorderWidth = Unit.Parse(border);

                AjaxEventsHelper.AddAjaxEventAttribute(this, AjaxEventType.onAjaxClick, ClientID, UniqueID, "__OSVSTATE", Attributes);
                base.AddAttributesToRender(writer);
            }
        }
Ejemplo n.º 6
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            using (var w = new HtmlTextWriterWithAttributeFilter(writer)) {
                base.AddAttributesToRender(w);
                ParentDataGrid.ViewStateAttributes.InlineAttributes.AddAttributes(w);

                if (_parentID != null)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Id, _parentID);
                }
            }
        }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            using (var w = new HtmlTextWriterWithAttributeFilter(writer)) {
                Page.VerifyRenderingInServerForm(this);

                w.AddAttribute(HtmlTextWriterAttribute.Name, base.UniqueID);

                bool old_Enabled = Enabled;
                if (!Enabled)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Disabled, ((OSPage)Page).QuirksMode ? null : "disabled");
                    Enabled = true;
                }

                // add to class='' the Mandatory style
                if (this._mandatory)
                {
                    string cssClass = this.CssClass;
                    if (cssClass != null && cssClass != "")
                    {
                        this.CssClass = this.CssClass + " Mandatory";
                    }
                    else
                    {
                        this.CssClass = "Mandatory";
                    }
                }

                // add to class='' the Valid style
                if (!this._valid)
                {
                    string cssClass = this.CssClass;
                    if (cssClass != null && cssClass != "")
                    {
                        this.CssClass = this.CssClass + " Not_Valid";
                    }
                    else
                    {
                        this.CssClass = "Not_Valid";
                    }
                }

                // dump ajax onchange handler
                AjaxEventsHelper.AddAjaxEventAttribute(this, AjaxEventType.onAjaxChange, ClientID, UniqueID, "__OSVSTATE", ViewStateAttributes.InlineAttributes);
                base.AddAttributesToRender(w);
                ViewStateAttributes.InlineAttributes.AddAttributes(w);
                Enabled = old_Enabled;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// This is exactly the same as in System.Web.UI.WebControls.LinkButton, only the javascript
        /// of the href attribute is diferent.
        /// This change was done to support FireFox (#37171)
        /// </summary>
        /// <param name="writer"></param>
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            using (var w = new HtmlTextWriterWithAttributeFilter(writer)) {
                if (Page != null)
                {
                    Page.VerifyRenderingInServerForm(this);
                }

                if (ID != null)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
                }

                if (AccessKey.Length > 0)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Accesskey, AccessKey);
                }

                if (!Enabled)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Disabled, ((OSPage)Page).QuirksMode ? null : "disabled");
                }

                if (TabIndex != 0)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Tabindex, TabIndex.ToString());
                }

                if (ToolTip.Length > 0)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Title, ToolTip);
                }

                if (ControlStyleCreated)
                {
                    ControlStyle.AddAttributesToRender(w, this);
                }

                bool isAjax = (events != null) && events.Contains(AjaxEventType.onAjaxClick);

                string onClickText = JavaScriptManager.GetButtonOnClickCode(ClientID, UniqueID, ViewStateAttributes.InlineAttributes["onclick"],
                                                                            _confirmMessage, isAjax, CausesValidation);

                if (onClickText.Length > 0)
                {
                    ViewStateAttributes.InlineAttributes["onclick"] = onClickText;
                }

                // remove the onclick javascript handler if the control is disabled
                if (!Enabled)
                {
                    ViewStateAttributes.InlineAttributes.Remove("onclick");
                }

                foreach (string attr in Attributes.Keys)
                {
                    w.AddAttribute(attr, Attributes[attr]);
                }

                ViewStateAttributes.InlineAttributes.AddAttributes(w);

                // "#"
                if (Enabled && (Page != null))
                {
                    string htmlTextAttribute = JavaScriptManager.GetLinkHRefCode(ClientID, isAjax, CausesValidation,
                                                                                 Page.ClientScript.GetPostBackEventReference(this, ""), Page.ClientScript.GetPostBackClientHyperlink(this, ""));

                    w.AddAttribute(HtmlTextWriterAttribute.Href, htmlTextAttribute);
                }
            }
        }
Ejemplo n.º 9
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            using (var w = new HtmlTextWriterWithAttributeFilter(writer)) {
                Page.VerifyRenderingInServerForm(this);

                w.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);

                TextBoxMode mode = this.TextMode;
                if (mode == TextBoxMode.MultiLine)
                {
                    int rows = this.Rows;
                    if (rows > 0)
                    {
                        w.AddAttribute(HtmlTextWriterAttribute.Rows, rows.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    int cols = this.Columns;
                    if (cols > 0)
                    {
                        w.AddAttribute(HtmlTextWriterAttribute.Cols, cols.ToString(NumberFormatInfo.InvariantInfo));
                    }
                }
                else
                {
                    if (mode == TextBoxMode.SingleLine)
                    {
                        w.AddAttribute(HtmlTextWriterAttribute.Type, "text");
                        string value = this.Text;
                        if (value.Length > 0)
                        {
                            w.AddAttribute(HtmlTextWriterAttribute.Value, value);
                        }
                    }
                    else if (mode == TextBoxMode.Password)
                    {
                        w.AddAttribute(HtmlTextWriterAttribute.Type, "password");
                    }

                    int ml = this.MaxLength;
                    if (ml > 0)
                    {
                        w.AddAttribute(HtmlTextWriterAttribute.Maxlength, ml.ToString(NumberFormatInfo.InvariantInfo));
                    }
                    int size = this.Columns;
                    if (size > 0)
                    {
                        w.AddAttribute(HtmlTextWriterAttribute.Size, size.ToString(NumberFormatInfo.InvariantInfo));
                    }
                }

                if (this.ReadOnly)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.ReadOnly, ((OSPage)Page).QuirksMode ? null : "readonly");
                }

                // [#35738] add to class='' the Mandatory style
                if (this._mandatory)
                {
                    string cssClass = this.CssClass;
                    if (cssClass != null && cssClass != "")
                    {
                        this.CssClass = this.CssClass + " Mandatory";
                    }
                    else
                    {
                        this.CssClass = "Mandatory";
                    }
                }

                // [#35738] add to class='' the Valid style
                if (!this._valid)
                {
                    string cssClass = this.CssClass;
                    if (cssClass != null && cssClass != "")
                    {
                        this.CssClass = this.CssClass + " Not_Valid";
                    }
                    else
                    {
                        this.CssClass = "Not_Valid";
                    }
                }

                // dump ajax onchange handler
                AjaxEventsHelper.AddAjaxEventAttribute(this, AjaxEventType.onAjaxChange, ClientID, UniqueID, "__OSVSTATE", ViewStateAttributes.InlineAttributes);
                base.AddAttributesToRender(w);
                ViewStateAttributes.InlineAttributes.AddAttributes(w);
            }
        }