本文整理汇总了C#中System.Web.UI.HtmlTextWriter.WriteTargetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.WriteTargetAttribute方法的具体用法?C# HtmlTextWriter.WriteTargetAttribute怎么用?C# HtmlTextWriter.WriteTargetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.WriteTargetAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildItem
/// <summary>
/// Builds the item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="writer">The writer.</param>
private void BuildItem(MenuItem item, HtmlTextWriter writer)
{
if (item != null && writer != null)
{
writer.WriteLine();
writer.WriteBeginTag("li");
string cssClass = (item.ChildItems.Count > 0) ? "dropdown" : "";
string selectedStatusClass = GetSelectStatusClass(item);
if (!String.IsNullOrEmpty(selectedStatusClass))
cssClass += " " + selectedStatusClass;
writer.WriteAttribute("class", cssClass);
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
if (IsLink(item))
{
writer.WriteBeginTag("a");
if (!String.IsNullOrEmpty(item.NavigateUrl))
writer.WriteAttribute("href", Page.Server.HtmlEncode(this.ResolveClientUrl(item.NavigateUrl)));
else
writer.WriteAttribute("href", Page.ClientScript.GetPostBackClientHyperlink(this, "b" + item.ValuePath.Replace(this.PathSeparator.ToString(), "\\"), true));
cssClass = GetItemClass(this, item);
writer.WriteAttribute("class", cssClass);
writer.WriteTargetAttribute(item.Target);
if (!String.IsNullOrEmpty(item.ToolTip))
writer.WriteAttribute("title", item.ToolTip);
else if (!String.IsNullOrEmpty(this.ToolTip))
writer.WriteAttribute("title", this.ToolTip);
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
writer.Write(item.Text);
writer.Indent--;
writer.WriteEndTag("a");
}
else if ((item.ChildItems != null) && (item.ChildItems.Count > 0))
{
//.btn-navbar is used as the toggle for collapsed navbar content
//<a class="dropdown-toggle" data-toggle="dropdown" href="#">Tables <b class="caret"></b></a>
writer.WriteBeginTag("a");
writer.WriteAttribute("class", "dropdown-toggle");
writer.WriteAttribute("data-toggle", "dropdown");
writer.WriteAttribute("href", "#");
writer.Write(HtmlTextWriter.TagRightChar);
writer.Write(item.Text);
// add space between text and caret
writer.Write(" ");
writer.WriteBeginTag("b");
writer.WriteAttribute("class", "caret");
writer.Write(HtmlTextWriter.TagRightChar);
writer.WriteEndTag("b");
writer.WriteEndTag("a");
BuildItems(item.ChildItems, false, writer);
}
else
{
// no link here this is just a menu item with no function
writer.WriteBeginTag("li");
writer.WriteAttribute("class", GetItemClass(this, item));
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
}
writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("li");
}
}