本文整理汇总了C#中System.Web.UI.WebControls.MenuItem.NotTemplated方法的典型用法代码示例。如果您正苦于以下问题:C# MenuItem.NotTemplated方法的具体用法?C# MenuItem.NotTemplated怎么用?C# MenuItem.NotTemplated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.MenuItem
的用法示例。
在下文中一共展示了MenuItem.NotTemplated方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderItem
protected virtual internal void RenderItem(HtmlTextWriter writer, MenuItem item, int position) {
Menu owner = Control;
MenuItemStyle mergedStyle = owner.GetMenuItemStyle(item);
string imageUrl = item.ImageUrl;
int depth = item.Depth;
int depthPlusOne = depth + 1;
string toolTip = item.ToolTip;
string navigateUrl = item.NavigateUrl;
string text = item.Text;
bool enabled = item.IsEnabled;
bool selectable = item.Selectable;
MenuItemCollection childItems = item.ChildItems;
// Top separator
string topSeparatorUrl = null;
if (depth < owner.StaticDisplayLevels && owner.StaticTopSeparatorImageUrl.Length != 0) {
topSeparatorUrl = owner.StaticTopSeparatorImageUrl;
}
else if (depth >= owner.StaticDisplayLevels && owner.DynamicTopSeparatorImageUrl.Length != 0) {
topSeparatorUrl = owner.DynamicTopSeparatorImageUrl;
}
if (topSeparatorUrl != null) {
Image separatorImage = new Image();
separatorImage.ImageUrl = topSeparatorUrl;
separatorImage.GenerateEmptyAlternateText = true; // XHtml compliance
separatorImage.Page = Page;
separatorImage.RenderControl(writer);
RenderBreak(writer);
}
// Don't render the top spacing if this is the first root item
if ((mergedStyle != null) && !mergedStyle.ItemSpacing.IsEmpty &&
((_titleItem != null) || (position != 0))) {
RenderSpace(writer, mergedStyle.ItemSpacing, owner.Orientation);
}
// Item span
Panel itemPanel = new SpanPanel();
itemPanel.Enabled = enabled;
itemPanel.Page = Page;
// Apply styles
if (Page != null && Page.SupportsStyleSheets) {
string styleClass = owner.GetCssClassName(item, false);
if (styleClass.Trim().Length > 0) {
itemPanel.CssClass = styleClass;
}
}
else if (mergedStyle != null) {
itemPanel.ApplyStyle(mergedStyle);
}
// Tooltip
if (item.ToolTip.Length != 0) {
itemPanel.ToolTip = item.ToolTip;
}
// Render item begin tag
itemPanel.RenderBeginTag(writer);
// If there is a navigation url on this item, set up the navigation stuff if:
// - the item is the current title item for this level
// - the item has no children
// - the item is a static item of depth + 1 < StaticDisplayLevels
bool clickOpensThisNode = !((position == 0) ||
(childItems.Count == 0) ||
(depthPlusOne < owner.StaticDisplayLevels) ||
(depthPlusOne >= owner.MaximumDepth));
// Indent
if (position != 0 &&
depth > 0 &&
owner.StaticSubMenuIndent != Unit.Pixel(0) &&
depth < owner.StaticDisplayLevels) {
Image spacerImage = new Image();
spacerImage.ImageUrl = owner.SpacerImageUrl;
spacerImage.GenerateEmptyAlternateText = true; // XHtml compliance
double indent = owner.StaticSubMenuIndent.Value * depth;
if (indent < Unit.MaxValue) {
spacerImage.Width = new Unit(indent, owner.StaticSubMenuIndent.Type);
}
else {
spacerImage.Width = new Unit(Unit.MaxValue, owner.StaticSubMenuIndent.Type);;
}
spacerImage.Height = Unit.Pixel(1);
spacerImage.Page = Page;
spacerImage.RenderControl(writer);
}
// Render out the item icon, if it is set and if the item is not templated (VSWhidbey 501618)
if (imageUrl.Length > 0 && item.NotTemplated()) {
Image newImage = new Image();
newImage.ImageUrl = imageUrl;
if (toolTip.Length != 0) {
newImage.AlternateText = toolTip;
}
else {
newImage.GenerateEmptyAlternateText = true; // XHtml compliance
}
//.........这里部分代码省略.........
示例2: RenderItem
protected internal virtual void RenderItem(HtmlTextWriter writer, MenuItem item, int position)
{
bool flag4;
string str6;
Menu control = this.Control;
MenuItemStyle menuItemStyle = control.GetMenuItemStyle(item);
string imageUrl = item.ImageUrl;
int depth = item.Depth;
int num2 = depth + 1;
string toolTip = item.ToolTip;
string navigateUrl = item.NavigateUrl;
string text = item.Text;
bool isEnabled = item.IsEnabled;
bool selectable = item.Selectable;
MenuItemCollection childItems = item.ChildItems;
string staticTopSeparatorImageUrl = null;
if ((depth < control.StaticDisplayLevels) && (control.StaticTopSeparatorImageUrl.Length != 0))
{
staticTopSeparatorImageUrl = control.StaticTopSeparatorImageUrl;
}
else if ((depth >= control.StaticDisplayLevels) && (control.DynamicTopSeparatorImageUrl.Length != 0))
{
staticTopSeparatorImageUrl = control.DynamicTopSeparatorImageUrl;
}
if (staticTopSeparatorImageUrl != null)
{
new Image { ImageUrl = staticTopSeparatorImageUrl, GenerateEmptyAlternateText = true, Page = base.Page }.RenderControl(writer);
this.RenderBreak(writer);
}
if (((menuItemStyle != null) && !menuItemStyle.ItemSpacing.IsEmpty) && ((this._titleItem != null) || (position != 0)))
{
this.RenderSpace(writer, menuItemStyle.ItemSpacing, control.Orientation);
}
Panel panel = new SpanPanel {
Enabled = isEnabled,
Page = base.Page
};
if ((base.Page != null) && base.Page.SupportsStyleSheets)
{
string cssClassName = control.GetCssClassName(item, false);
if (cssClassName.Trim().Length > 0)
{
panel.CssClass = cssClassName;
}
}
else if (menuItemStyle != null)
{
panel.ApplyStyle(menuItemStyle);
}
if (item.ToolTip.Length != 0)
{
panel.ToolTip = item.ToolTip;
}
panel.RenderBeginTag(writer);
bool flag3 = (((position != 0) && (childItems.Count != 0)) && (num2 >= control.StaticDisplayLevels)) && (num2 < control.MaximumDepth);
if (((position != 0) && (depth > 0)) && ((control.StaticSubMenuIndent != Unit.Pixel(0)) && (depth < control.StaticDisplayLevels)))
{
Image image2 = new Image {
ImageUrl = control.SpacerImageUrl,
GenerateEmptyAlternateText = true
};
double num3 = control.StaticSubMenuIndent.Value * depth;
if (num3 < 32767.0)
{
image2.Width = new Unit(num3, control.StaticSubMenuIndent.Type);
}
else
{
image2.Width = new Unit(32767.0, control.StaticSubMenuIndent.Type);
}
image2.Height = Unit.Pixel(1);
image2.Page = base.Page;
image2.RenderControl(writer);
}
if ((imageUrl.Length > 0) && item.NotTemplated())
{
Image image3 = new Image {
ImageUrl = imageUrl
};
if (toolTip.Length != 0)
{
image3.AlternateText = toolTip;
}
else
{
image3.GenerateEmptyAlternateText = true;
}
image3.Page = base.Page;
image3.RenderControl(writer);
writer.Write(' ');
}
if ((base.Page != null) && base.Page.SupportsStyleSheets)
{
str6 = control.GetCssClassName(item, true, out flag4);
}
else
{
str6 = string.Empty;
flag4 = false;
}
//.........这里部分代码省略.........
示例3: RenderItemIcon
private void RenderItemIcon(HtmlTextWriter writer, MenuItem item) {
if (String.IsNullOrEmpty(item.ImageUrl) || !item.NotTemplated()) {
return;
}
writer.AddAttribute(HtmlTextWriterAttribute.Src, Menu.ResolveClientUrl(item.ImageUrl));
writer.AddAttribute(HtmlTextWriterAttribute.Alt, item.ToolTip);
writer.AddAttribute(HtmlTextWriterAttribute.Title, item.ToolTip);
writer.AddAttribute(HtmlTextWriterAttribute.Class, "icon");
writer.RenderBeginTag(HtmlTextWriterTag.Img);
writer.RenderEndTag();
}