コード例 #1
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            Page page = Page;

            if (page != null)
            {
                page.VerifyRenderingInServerForm(this);
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Type, UseSubmitBehavior ? "submit" : "button", false);
            writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
            writer.AddAttribute(HtmlTextWriterAttribute.Value, Text);

            string onclick = OnClientClick;

            onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick);
            if (HasAttributes && Attributes ["onclick"] != null)
            {
                onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick + Attributes ["onclick"]);
                Attributes.Remove("onclick");
            }

            if (page != null)
            {
                onclick += GetClientScriptEventReference();
            }

            if (onclick.Length > 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick);
            }

            base.AddAttributesToRender(writer);
        }
コード例 #2
0
        protected override void AddAttributesToRender(HtmlTextWriter w)
        {
            Page page = Page;

            if (page != null)
            {
                page.VerifyRenderingInServerForm(this);
            }

            base.AddAttributesToRender(w);
            bool   enabled = IsEnabled;
            string onclick = OnClientClick;

            onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick);
            if (HasAttributes && Attributes ["onclick"] != null)
            {
                onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick + Attributes ["onclick"]);
                Attributes.Remove("onclick");
            }

            if (onclick.Length > 0)
            {
                w.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick);
            }

            if (enabled && page != null)
            {
                PostBackOptions options = GetPostBackOptions();
                string          href    = page.ClientScript.GetPostBackEventReference(options, true);
                w.AddAttribute(HtmlTextWriterAttribute.Href, href);
            }

            AddDisplayStyleAttribute(w);
        }
コード例 #3
0
        void RenderInput(HtmlTextWriter w, bool enabled)
        {
            if (ClientID != null && ClientID.Length > 0)
            {
                w.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
            }
            w.AddAttribute(HtmlTextWriterAttribute.Type, render_type);
            string nameAttr = NameAttribute;

            if (nameAttr != null && nameAttr.Length > 0)
            {
                w.AddAttribute(HtmlTextWriterAttribute.Name, nameAttr);
            }
            InternalAddAttributesToRender(w, enabled);
            AddAttributesToRender(w);

            if (Checked)
            {
                w.AddAttribute(HtmlTextWriterAttribute.Checked, "checked", false);
            }

            if (AutoPostBack)
            {
                Page   page    = Page;
                string onclick = page != null?page.ClientScript.GetPostBackEventReference(GetPostBackOptions(), true) : String.Empty;

                onclick = String.Concat("setTimeout('", onclick.Replace("\\", "\\\\").Replace("'", "\\'"), "', 0)");
                if (common_attrs != null && common_attrs ["onclick"] != null)
                {
                    onclick = ClientScriptManager.EnsureEndsWithSemicolon(common_attrs ["onclick"]) + onclick;
                    common_attrs.Remove("onclick");
                }
                w.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick);
            }

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

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

            if (common_attrs != null)
            {
                common_attrs.AddAttributes(w);
            }

            if (inputAttributes != null)
            {
                inputAttributes.AddAttributes(w);
            }

            w.RenderBeginTag(HtmlTextWriterTag.Input);
            w.RenderEndTag();
        }
コード例 #4
0
        protected override void RenderAttributes(HtmlTextWriter writer)
        {
#if NET_2_0
            CultureInfo inv        = Helpers.InvariantCulture;
            string      input_type = Type;
            if (0 != String.Compare(input_type, "reset", true, inv) &&
                ((0 == String.Compare(input_type, "submit", true, inv)) ||
                 (0 == String.Compare(input_type, "button", true, inv) && Events [ServerClickEvent] != null)))
            {
                string onclick = String.Empty;
                if (Attributes ["onclick"] != null)
                {
                    onclick = ClientScriptManager.EnsureEndsWithSemicolon(Attributes ["onclick"] + onclick);
                    Attributes.Remove("onclick");
                }
                if (Page != null)
                {
                    PostBackOptions options = GetPostBackOptions();
                    onclick += Page.ClientScript.GetPostBackEventReference(options, true);
                }

                if (onclick.Length > 0)
                {
                    writer.WriteAttribute("onclick", onclick, true);
                    writer.WriteAttribute("language", "javascript");
                }
            }
#else
            if (RenderOnClick())
            {
                string oc = null;
                ClientScriptManager csm = new ClientScriptManager(Page);
                if (Page.AreValidatorsUplevel())
                {
                    oc = csm.GetClientValidationEvent();
                }
                else if (Events [ServerClickEvent] != null)
                {
                    oc = Attributes ["onclick"] + " " + csm.GetPostBackEventReference(this, "");
                }

                if (oc != null)
                {
                    writer.WriteAttribute("language", "javascript");
                    writer.WriteAttribute("onclick", oc, true);
                }
            }
#endif

            Attributes.Remove("CausesValidation");
#if NET_2_0
            // LAMESPEC: MS doesn't actually remove this
            //attribute.  it shows up in the rendered
            //output.

            // Attributes.Remove("ValidationGroup");
#endif
            base.RenderAttributes(writer);
        }
コード例 #5
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            if (Page != null)
            {
                Page.VerifyRenderingInServerForm(this);
            }

#if NET_2_0
            writer.AddAttribute(HtmlTextWriterAttribute.Type, UseSubmitBehavior ? "submit" : "button", false);
            writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
            writer.AddAttribute(HtmlTextWriterAttribute.Value, Text);

            string onclick = OnClientClick;
            onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick);
            if (HasAttributes && Attributes ["onclick"] != null)
            {
                onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick + Attributes ["onclick"]);
                Attributes.Remove("onclick");
            }

            if (Page != null)
            {
                onclick += GetClientScriptEventReference();
            }

            if (onclick.Length > 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick);
            }
#else
            writer.AddAttribute(HtmlTextWriterAttribute.Type, "submit");
            writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
            writer.AddAttribute(HtmlTextWriterAttribute.Value, Text);

            if (CausesValidation && Page != null && Page.AreValidatorsUplevel())
            {
                string onclick = Attributes["onclick"];
                if (onclick != null)
                {
                    Attributes.Remove("onclick");
                    int len = onclick.Length;
                    if (len > 0 && onclick[len - 1] != ';')
                    {
                        onclick += ";";
                    }
                }
                ClientScriptManager csm = new ClientScriptManager(Page);
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick + csm.GetClientValidationEvent());
                writer.AddAttribute("language", "javascript");
            }
#endif

            base.AddAttributesToRender(writer);
        }
コード例 #6
0
        protected override void AddAttributesToRender(HtmlTextWriter w)
        {
            Page page = Page;

            if (page != null)
            {
                page.VerifyRenderingInServerForm(this);
            }

            bool enabled = IsEnabled;

#if NET_2_0
            string onclick = OnClientClick;
            onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick);
            if (HasAttributes && Attributes ["onclick"] != null)
            {
                onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick + Attributes ["onclick"]);
                Attributes.Remove("onclick");
            }

            if (onclick.Length > 0)
            {
                w.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick);
            }

            if (enabled && page != null)
            {
                PostBackOptions options = GetPostBackOptions();
                string          href    = page.ClientScript.GetPostBackEventReference(options, true);
                w.AddAttribute(HtmlTextWriterAttribute.Href, href);
            }
            base.AddAttributesToRender(w);
            AddDisplayStyleAttribute(w);
#else
            base.AddAttributesToRender(w);
            if (page == null || !enabled)
            {
                return;
            }

            if (CausesValidation && page.AreValidatorsUplevel())
            {
                ClientScriptManager csm = new ClientScriptManager(page);
                w.AddAttribute(HtmlTextWriterAttribute.Href,
                               String.Concat("javascript:{if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); ",
                                             csm.GetPostBackEventReference(this, String.Empty), ";}"));
            }
            else
            {
                w.AddAttribute(HtmlTextWriterAttribute.Href, page.ClientScript.GetPostBackClientHyperlink(this, String.Empty));
            }
#endif
        }
コード例 #7
0
        protected internal override void Render(HtmlTextWriter writer)
        {
            EnsureForeColor();
            if (AllowCallback)
            {
                ICallbackContainer ccner = Container as ICallbackContainer;
                if (ccner != null)
                {
                    OnClientClick = ClientScriptManager.EnsureEndsWithSemicolon(OnClientClick) + ccner.GetCallbackScript(this, CommandName + "$" + CommandArgument);
                }
            }

            base.Render(writer);
        }
コード例 #8
0
ファイル: ImageButton.cs プロジェクト: mdae/MonoRT
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            Page page = Page;

            if (page != null)
            {
                page.VerifyRenderingInServerForm(this);
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Type, "image", false);
            writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);

            base.AddAttributesToRender(writer);
#if NET_2_0
            string onclick = OnClientClick;
            if (!String.IsNullOrEmpty(onclick))
            {
                onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick);
            }
            else
            {
                onclick = String.Empty;
            }

            if (HasAttributes && Attributes ["onclick"] != null)
            {
                onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick + Attributes ["onclick"]);
                Attributes.Remove("onclick");
            }

            if (page != null)
            {
                onclick += GetClientScriptEventReference();
            }

            if (onclick.Length > 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick);
            }
#else
            if (CausesValidation && page != null && page.AreValidatorsUplevel())
            {
                ClientScriptManager csm = new ClientScriptManager(page);
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, csm.GetClientValidationEvent());
                writer.AddAttribute("language", "javascript");
            }
#endif
        }
コード例 #9
0
        protected override void RenderAttributes(HtmlTextWriter writer)
        {
            CultureInfo inv        = Helpers.InvariantCulture;
            string      input_type = Type;

            if (0 != String.Compare(input_type, "reset", true, inv) &&
                ((0 == String.Compare(input_type, "submit", true, inv)) ||
                 (0 == String.Compare(input_type, "button", true, inv) && Events [ServerClickEvent] != null)))
            {
                string onclick = String.Empty;
                if (Attributes ["onclick"] != null)
                {
                    onclick = ClientScriptManager.EnsureEndsWithSemicolon(Attributes ["onclick"] + onclick);
                    Attributes.Remove("onclick");
                }

                Page page = Page;
                if (page != null)
                {
                    PostBackOptions options = GetPostBackOptions();
                    onclick += page.ClientScript.GetPostBackEventReference(options, true);
                }

                if (onclick.Length > 0)
                {
                    bool encode = true;
                    if (Events [ServerClickEvent] != null)
                    {
                        encode = false;                         // tests show that this is indeed
                    }
                    // the case...
                    writer.WriteAttribute("onclick", onclick, encode);
                    writer.WriteAttribute("language", "javascript");
                }
            }

            Attributes.Remove("CausesValidation");
            // LAMESPEC: MS doesn't actually remove this
            //attribute.  it shows up in the rendered
            //output.

            // Attributes.Remove("ValidationGroup");
            base.RenderAttributes(writer);
        }
コード例 #10
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            Page page = Page;

            if (page != null)
            {
                page.VerifyRenderingInServerForm(this);
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Type, "image", false);
            writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);

            base.AddAttributesToRender(writer);

            string onclick = OnClientClick;

            if (!String.IsNullOrEmpty(onclick))
            {
                onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick);
            }
            else
            {
                onclick = String.Empty;
            }

            if (HasAttributes && Attributes ["onclick"] != null)
            {
                onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick + Attributes ["onclick"]);
                Attributes.Remove("onclick");
            }

            if (page != null)
            {
                onclick += GetClientScriptEventReference();
            }

            if (onclick.Length > 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick);
            }
        }