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


C# HtmlTextWriter.WriteAttribute方法代码示例

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


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

示例1: RenderAttributes

        /// <summary>
        /// The RenderAttributes method adds the attributes to the rendered &lt;form&gt; tag.
        /// We override this method so that the action attribute is not emitted.
        /// </summary>
        protected override void RenderAttributes(HtmlTextWriter writer)
        {
            // write the form's name
            writer.WriteAttribute("name", this.Name);
            base.Attributes.Remove("name");

            // write the form's method
            writer.WriteAttribute("method", this.Method);
            base.Attributes.Remove("method");

            this.Attributes.Render(writer);

            // remove the action attribute
            String action = Context.Request.RawUrl;
            if (action != null)
            {
                writer.WriteAttribute("action", action);
            }

            base.Attributes.Remove("action");

            // finally write all other attributes
            this.Attributes.Render(writer);

            if (base.ID != null)
                writer.WriteAttribute("id", base.ClientID);
        }
开发者ID:rupendra-sharma07,项目名称:MainTrunk,代码行数:31,代码来源:ActionlessForm.cs

示例2: Render

 protected override void Render(HtmlTextWriter writer)
 {
     writer.WriteBeginTag("paper-button");
     writer.WriteAttribute("ID", this.ID);
     if (ButtonType == PaperButtonType.NoInk)
     {
         writer.Write(HtmlTextWriter.SpaceChar);
         writer.Write("noink");
     }
     else if (ButtonType == PaperButtonType.Raised)
     {
         writer.Write(HtmlTextWriter.SpaceChar);
         writer.Write("raised");
     }
     else if (ButtonType == PaperButtonType.Toggles)
     {
         writer.Write(HtmlTextWriter.SpaceChar);
         writer.Write("toggles");
     }
     if (!string.IsNullOrWhiteSpace(CssClass))
     {
         writer.WriteAttribute("class", CssClass);
     }
     writer.Write(HtmlTextWriter.TagRightChar);
     if (Icon != null)
     {
         writer.Write(Icon.ToString());
     }
     if (!string.IsNullOrWhiteSpace(Text))
     {
         writer.Write(Text);
     }
     writer.WriteEndTag("paper-button");
 }
开发者ID:soham85,项目名称:Polymer.NET,代码行数:34,代码来源:PaperButton.cs

示例3: RenderAttributes

		protected override void RenderAttributes (HtmlTextWriter writer)
		{
			if (Page != null && CausesValidation) {
				string type = Type;
				if (String.Compare (type, "button", true) == 0 || String.Compare (type, "submit", true) == 0) {
					string script = Page.ClientScript.GetPostBackClientEvent (this, String.Empty);
					if (script != null && 
						((String.Compare (type, "button", true) == 0  && Events[EventServerClick] != null )|| 
						 (String.Compare (type, "submit", true) == 0 && Page.Validators.Count > 0))){
						AttributeCollection coll = Attributes;
						if (coll ["language"] != null)
							coll.Remove ("language");
						writer.WriteAttribute ("language", "javascript");

						string onclick;
						if ((onclick = coll ["onclick"]) != null) {
							script = onclick + " " + script;
							coll.Remove ("onclick");
						}
						
						writer.WriteAttribute ("onclick", script);
					}
				}
			}
			
			base.RenderAttributes (writer);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:27,代码来源:HtmlInputButton.cs

示例4: RenderBeginTag

 public override void RenderBeginTag(HtmlTextWriter writer)
 {
     writer.WriteBeginTag("div");
     writer.WriteAttribute("id", this.UniqueID);
     if (this.CssClass != string.Empty) writer.WriteAttribute("class", this.CssClass);
     writer.Write(HtmlTextWriter.TagRightChar);
 }
开发者ID:charlest704,项目名称:Lad-Solution,代码行数:7,代码来源:Frame.cs

示例5: RenderContents

        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (Extender.AdapterEnabled)
            {
                LinkButton linkButton = Control as LinkButton;
                if (linkButton != null)
                {
                    string className = (!String.IsNullOrEmpty(linkButton.CssClass)) ? (linkButton.CssClass) : "AspNet-LinkButton";

                    Control ctl = linkButton.FindControl("ctl00");
                    if (ctl != null)
                    {
                        writer.WriteBeginTag("a");
                        writer.WriteAttribute("id", linkButton.ClientID);
                        writer.WriteAttribute("title", linkButton.ToolTip);
                        writer.WriteAttribute("class", className);
                        writer.WriteAttribute("href", Page.ClientScript.GetPostBackClientHyperlink(linkButton, ""));
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.WriteBeginTag("span");
                        writer.WriteAttribute("class", "AspNet-LinkButton-Text");
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Write(linkButton.Text);
                        writer.WriteEndTag("span");
                        writer.WriteEndTag("a"); Page.ClientScript.RegisterForEventValidation(linkButton.UniqueID);
                    }
                    else
                    {
                        base.RenderContents(writer);
                    }
                }
            }
        }
开发者ID:JenasysDesign,项目名称:BootstrapControlAdapters,代码行数:32,代码来源:LinkButtonAdapter.cs

示例6: WriteOnClickAttribute

		public void WriteOnClickAttribute(HtmlTextWriter writer, HtmlControl control, bool submitsAutomatically, bool submitsProgramatically, bool causesValidation, string validationGroup) {
			var attributes = control.Attributes;
			string clientValidateEvent = null;
			if(submitsAutomatically) {
				if(causesValidation) {
					clientValidateEvent = GetClientValidateEvent(validationGroup);
				}
				control.Page.ClientScript.RegisterForEventValidation(control.UniqueID);
			} else if(submitsProgramatically) {
				if(causesValidation) {
					clientValidateEvent = GetClientValidatedPostback(control, validationGroup);
				} else {
					clientValidateEvent = control.Page.ClientScript.GetPostBackEventReference(control, string.Empty, true);
				}
			} else {
				control.Page.ClientScript.RegisterForEventValidation(control.UniqueID);
			}
			if(clientValidateEvent != null) {
				if(attributes["language"] != null) {
					attributes.Remove("language");
				}
				writer.WriteAttribute("language", "javascript");
				var onClick = attributes["onclick"];
				if(onClick != null) {
					attributes.Remove("onclick");
					writer.WriteAttribute("onclick", string.Format("{0} {1}", onClick, clientValidateEvent));
				} else {
					writer.WriteAttribute("onclick", clientValidateEvent);
				}
			}
		}
开发者ID:aelveborn,项目名称:njupiter,代码行数:31,代码来源:ControlHandlerImpl.cs

示例7: RenderMetaTag

 private void RenderMetaTag(HtmlTextWriter writer, string name, string content)
 {
     writer.WriteBeginTag("meta");
     writer.WriteAttribute("name",name,true);
     writer.WriteAttribute("content",content,true);
     writer.WriteLine(HtmlTextWriter.SelfClosingTagEnd);
 }
开发者ID:sffogg,项目名称:Xenosynth,代码行数:7,代码来源:MetaTag.cs

示例8: Render

        protected override void Render(HtmlTextWriter writer)
        {
            Button button = this.Control;

            writer.WriteBeginTag("button"); // <button 
            writer.WriteAttribute("value", "submit"); // <button value="submit" 
            writer.WriteAttribute("id", button.ClientID); // <button value="submit" id="btnButton"

            PostBackOptions myPostBackOptions = new PostBackOptions(button);
            //Add the Postback event
            if (button.Page.ClientScript.GetPostBackEventReference(myPostBackOptions).Length > 0)
            {
                //Turn on Validation if it needs to be on...
                if (button.CausesValidation)
                    myPostBackOptions.PerformValidation = true;

                //Need to replace double quotes with single quotes for javascript to work.
                writer.WriteAttribute("onclick", button.Page.ClientScript.GetPostBackEventReference(myPostBackOptions).Replace("\"", "'")); // <button value="submit" 

                //Register the Event
                button.Page.ClientScript.RegisterForEventValidation(myPostBackOptions);
            } // <button value="submit" id="btnButton" onclick="__doPostBack('btnButton','')"

            if (button.CssClass.Length > 0)
                writer.WriteAttribute("class", button.CssClass); // <button value="submit" id="btnButton" onclick="__doPostBack('btnButton','')" class="large-button"

            writer.Write(HtmlTextWriter.TagRightChar); // <button value="submit" id="btnButton" onclick="__doPostBack('btnButton','')" class="large-button">
            writer.WriteFullBeginTag("span");
            writer.Write(button.Text);
            writer.WriteEndTag("span"); // <button value="submit" id="btnButton" onclick="__doPostBack('btnButton','')" class="large-button"><span>testButton</span>
            writer.WriteEndTag("button"); // <button value="submit" id="btnButton" onclick="__doPostBack('btnButton','')" class="large-button"><span>testButton</span></button>
        }
开发者ID:JBeans99,项目名称:CSharp__.NET,代码行数:32,代码来源:ButtonAdapter.cs

示例9: RenderAttributes

        protected override void RenderAttributes(HtmlTextWriter writer)
        {
            base.RenderAttributes(writer);
            if (!string.IsNullOrEmpty(ID))
                writer.WriteAttribute("id", this.ClientID);
            if (this.CssClass.Length > 0)
				writer.WriteAttribute("class", this.CssClass + (this.Disabled ? " disabled" : string.Empty));
        }
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:8,代码来源:FieldSet.cs

示例10: RenderBlank

		private void RenderBlank (HtmlTextWriter writer)
		{
			writer.WriteBeginTag ("td");
			writer.WriteAttribute ("bgcolor", TabBackColor);
			writer.WriteAttribute ("width", BlankWidth.ToString ());
			writer.Write (">");
			writer.Write ("&nbsp;");
			writer.WriteEndTag ("td");
		}
开发者ID:louislatreille,项目名称:xsp,代码行数:9,代码来源:tabcontrol.cs

示例11: Render

		protected override void Render(HtmlTextWriter writer)
		{
			writer.WriteBeginTag("script");
			writer.WriteAttribute("type", "text/javascript");
			writer.WriteAttribute("src", url + "?" + JavaScripts);
			writer.Write(HtmlTextWriter.TagRightChar);
			writer.WriteEndTag("script");
			writer.WriteLine();
		}
开发者ID:elementar,项目名称:Suprifattus.Util,代码行数:9,代码来源:JavaScriptReference.cs

示例12: DoRender

 private void DoRender(HtmlTextWriter writer)
 {
     writer.WriteBeginTag("iframe");
     writer.WriteAttribute("src", SiteUtils.GetNavigationSiteRoot() + "/Services/SessionKeepAlive.aspx");
     writer.WriteAttribute("frameborder", "0");
     writer.WriteAttribute("width", "0");
     writer.WriteAttribute("height", "0");
     writer.Write(HtmlTextWriter.TagRightChar);
     writer.WriteEndTag("iframe");
 }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:10,代码来源:SessionKeepAliveControl.cs

示例13: ShowPropertyGrid

        /// <summary>
        /// Creates a simplistic Property Grid to display of an object
        /// </summary>
        /// <returns></returns>
        public static string ShowPropertyGrid(object sourceObject)
        {
            if (sourceObject == null)
                return "<hr/>No object passed.<hr/>";

            StringBuilder sb = new StringBuilder();
            using (StringWriter sw = new StringWriter(sb))
            {
                using (HtmlTextWriter hWriter = new HtmlTextWriter(sw))
                {
                    hWriter.WriteBeginTag("table");
                    hWriter.WriteAttribute("border", "1");
                    hWriter.WriteAttribute("cellpadding", "5");
                    hWriter.WriteAttribute("class", "table table-bordered table-striped");
                    hWriter.Write(" style='border-collapse:collapse;'");
                    hWriter.Write(HtmlTextWriter.TagRightChar);
                    MemberInfo[] miT = sourceObject.GetType().FindMembers(MemberTypes.Field | MemberTypes.Property, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, null);
                    foreach (MemberInfo Field in miT)
                    {
                        string Name = Field.Name;
                        object Value = null;
                        if (Field.MemberType == MemberTypes.Field)
                        {
                            Value = ((FieldInfo)Field).GetValue(sourceObject);
                            continue;
                        }
                        else
                            if (Field.MemberType == MemberTypes.Property)
                                Value = ((PropertyInfo)Field).GetValue(sourceObject, null);
                        hWriter.WriteFullBeginTag("tr");
                        hWriter.WriteFullBeginTag("td");
                        hWriter.Write(Name);
                        hWriter.WriteEndTag("td");
                        hWriter.WriteLine();
                        hWriter.WriteFullBeginTag("td");
                        hWriter.WriteBeginTag("input");
                        hWriter.WriteAttribute("name", "Configuration." + Name);
                        hWriter.WriteAttribute("value", ReflectionUtils.TypedValueToString(Value));
                        hWriter.Write(" style='Width:400px' ");
                        hWriter.Write(HtmlTextWriter.TagRightChar);
                        hWriter.WriteEndTag("td");
                        hWriter.WriteLine();
                        hWriter.WriteEndTag("tr");
                        hWriter.WriteLine();
                    }
                    hWriter.WriteEndTag("table");
                    //string TableResult = sb.ToString();
                    hWriter.Close();
                }
                sw.Close();
            }

            return sb.ToString();
        }
开发者ID:Acaspita,项目名称:Westwind.ApplicationConfiguration,代码行数:58,代码来源:SamplesViewModel.cs

示例14: RenderAttributes

        protected override void RenderAttributes(HtmlTextWriter writer)
        {
            base.RenderAttributes(writer);

            if (this.Href != null)
            {
                writer.WriteAttribute("href", this.Href);
            }

            writer.WriteAttribute("type", "text/css");
            writer.WriteAttribute("rel", "stylesheet");
        }
开发者ID:jmangelo,项目名称:Inthros,代码行数:12,代码来源:StyleSheetLink.cs

示例15: Render

        protected override void Render(HtmlTextWriter writer)
        {
            int rowCount = 0;
            writer.WriteBeginTag("table");
            writer.WriteAttribute("id", this.ClientID);
            writer.WriteAttribute("class", this.CssClass);
            writer.WriteAttribute("summary", this.TableSummary);
            writer.Write(HtmlTextWriter.TagRightChar);

            foreach (RepeaterItem ri in Items)
            {
                if (rowCount == 0)
                {
                    writer.WriteBeginTag("tr");
                    writer.Write(HtmlTextWriter.TagRightChar);
                }

                writer.WriteBeginTag("td");
                writer.Write(HtmlTextWriter.TagRightChar);
                ri.RenderControl(writer);
                writer.WriteEndTag("td");

                if (rowCount == this.ColumnCount - 1)
                {
                    writer.WriteEndTag("tr");
                    rowCount = 0;
                }
                else
                {
                    rowCount++;
                }
            }

            if (rowCount > 0)
            {
                //write any remaining td's
                while (rowCount < this.ColumnCount)
                {
                    writer.WriteBeginTag("td");
                    writer.Write(HtmlTextWriter.TagRightChar);
                    writer.Write("&nbsp;");
                    writer.WriteEndTag("td");
                    rowCount++;
                }

                writer.WriteEndTag("tr");
                //writer.cl
            }

            writer.WriteEndTag("table");
        }
开发者ID:rrmarriott,项目名称:DirectSports,代码行数:51,代码来源:ProductLister.cs


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