当前位置: 首页>>代码示例>>C#>>正文


C# HtmlTextWriter.IsValidFormAttribute方法代码示例

本文整理汇总了C#中System.Web.UI.HtmlTextWriter.IsValidFormAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.IsValidFormAttribute方法的具体用法?C# HtmlTextWriter.IsValidFormAttribute怎么用?C# HtmlTextWriter.IsValidFormAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.HtmlTextWriter的用法示例。


在下文中一共展示了HtmlTextWriter.IsValidFormAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderAttributes

 protected override void RenderAttributes(HtmlTextWriter writer)
 {
     ArrayList list = new ArrayList();
     foreach (string str in base.Attributes.Keys)
     {
         if (!writer.IsValidFormAttribute(str))
         {
             list.Add(str);
         }
     }
     foreach (string str2 in list)
     {
         base.Attributes.Remove(str2);
     }
     bool enableLegacyRendering = base.EnableLegacyRendering;
     Page page = this.Page;
     if (writer.IsValidFormAttribute("name"))
     {
         if ((((page != null) && (page.RequestInternal != null)) && (this.RenderingCompatibility < VersionUtil.Framework40)) && ((page.RequestInternal.Browser.W3CDomVersion.Major == 0) || (page.XhtmlConformanceMode != XhtmlConformanceMode.Strict)))
         {
             writer.WriteAttribute("name", this.Name);
         }
         base.Attributes.Remove("name");
     }
     writer.WriteAttribute("method", this.Method);
     base.Attributes.Remove("method");
     writer.WriteAttribute("action", this.GetActionAttribute(), true);
     base.Attributes.Remove("action");
     if (page != null)
     {
         string clientOnSubmitEvent = page.ClientOnSubmitEvent;
         if (!string.IsNullOrEmpty(clientOnSubmitEvent))
         {
             if (base.Attributes["onsubmit"] != null)
             {
                 string s = base.Attributes["onsubmit"];
                 if (s.Length > 0)
                 {
                     if (!StringUtil.StringEndsWith(s, ';'))
                     {
                         s = s + ";";
                     }
                     if (page.ClientSupportsJavaScript || !s.ToLower(CultureInfo.CurrentCulture).Contains("javascript"))
                     {
                         page.ClientScript.RegisterOnSubmitStatement(typeof(HtmlForm), "OnSubmitScript", s);
                     }
                     base.Attributes.Remove("onsubmit");
                 }
             }
             if (page.ClientSupportsJavaScript || !clientOnSubmitEvent.ToLower(CultureInfo.CurrentCulture).Contains("javascript"))
             {
                 if (enableLegacyRendering)
                 {
                     writer.WriteAttribute("language", "javascript", false);
                 }
                 writer.WriteAttribute("onsubmit", clientOnSubmitEvent);
             }
         }
         if (((page.RequestInternal != null) && (page.RequestInternal.Browser.EcmaScriptVersion.Major > 0)) && ((page.RequestInternal.Browser.W3CDomVersion.Major > 0) && (this.DefaultButton.Length > 0)))
         {
             Control button = this.FindControl(this.DefaultButton);
             if ((button == null) && (this.Page != null))
             {
                 char[] anyOf = new char[] { '$', ':' };
                 if (this.DefaultButton.IndexOfAny(anyOf) != -1)
                 {
                     button = this.Page.FindControl(this.DefaultButton);
                 }
             }
             if (!(button is IButtonControl))
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("HtmlForm_OnlyIButtonControlCanBeDefaultButton", new object[] { this.ID }));
             }
             page.ClientScript.RegisterDefaultButtonScript(button, writer, false);
         }
     }
     base.EnsureID();
     base.RenderAttributes(writer);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:79,代码来源:HtmlForm.cs

示例2: RenderAttributes

        /// <internalonly/>
        /// <devdoc>
        /// </devdoc>
        protected override void RenderAttributes(HtmlTextWriter writer) {
            ArrayList invalidAttributes = new ArrayList();
            foreach (String key in Attributes.Keys) {
                if (!writer.IsValidFormAttribute(key)) {
                    invalidAttributes.Add(key);
                }
            }

            foreach (String key in invalidAttributes) {
                Attributes.Remove(key);
            }

            bool enableLegacyRendering = EnableLegacyRendering;

            Page page = Page;
            if (writer.IsValidFormAttribute("name")) {
                // DevDiv 27328 Do not render name attribute for uplevel browser
                if (page != null && page.RequestInternal != null &&
                    RenderingCompatibility < VersionUtil.Framework40 &&
                    (page.RequestInternal.Browser.W3CDomVersion.Major == 0 ||
                     page.XhtmlConformanceMode != XhtmlConformanceMode.Strict)) {
                    writer.WriteAttribute("name", Name);
                }
                Attributes.Remove("name");
            }

            writer.WriteAttribute("method", Method);
            Attributes.Remove("method");

            // Encode the action attribute - ASURT 66784
            writer.WriteAttribute("action", GetActionAttribute(), true /*encode*/);
            Attributes.Remove("action");

            // see if the page has a submit event
            if (page != null) {
                string onSubmit = page.ClientOnSubmitEvent;
                if (!String.IsNullOrEmpty(onSubmit)) {
                    if (Attributes["onsubmit"] != null) {
                        // If there was an onsubmit on the form, register it as an onsubmit statement and remove it from the attribute collection
                        string formOnSubmit = Attributes["onsubmit"];
                        if (formOnSubmit.Length > 0) {
                            if (!StringUtil.StringEndsWith(formOnSubmit, ';')) {
                                formOnSubmit += ";";
                            }
                            if (page.ClientSupportsJavaScript || !formOnSubmit.ToLower(CultureInfo.CurrentCulture).Contains("javascript")) {
                                page.ClientScript.RegisterOnSubmitStatement(typeof(HtmlForm), "OnSubmitScript", formOnSubmit);
                            }
                            Attributes.Remove("onsubmit");
                        }
                    }

                    // Don't render the on submit if it contains javascript and the page doesn't support it
                    if (page.ClientSupportsJavaScript || !onSubmit.ToLower(CultureInfo.CurrentCulture).Contains("javascript")) {
                        if (enableLegacyRendering) {
                            writer.WriteAttribute("language", "javascript", false);
                        }
                        writer.WriteAttribute("onsubmit", onSubmit);
                    }
                }

                if ((page.RequestInternal != null) &&
                    (page.RequestInternal.Browser.EcmaScriptVersion.Major > 0) &&
                    (page.RequestInternal.Browser.W3CDomVersion.Major > 0)) {
                    if (DefaultButton.Length > 0) {
                        // Find control from the page if it's a hierarchical ID.
                        // Dev11 bug 19915
                        Control c = FindControlFromPageIfNecessary(DefaultButton);

                        if (c is IButtonControl) {
                            page.ClientScript.RegisterDefaultButtonScript(c, writer, false /* UseAddAttribute */);
                        }
                        else {
                            throw new InvalidOperationException(SR.GetString(SR.HtmlForm_OnlyIButtonControlCanBeDefaultButton, ID));
                        }
                    }
                }
            }


            // We always want the form to have an id on the client
            // base.RenderAttributes takes care of actually rendering it.
            EnsureID();

            base.RenderAttributes(writer);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:88,代码来源:HtmlForm.cs


注:本文中的System.Web.UI.HtmlTextWriter.IsValidFormAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。