本文整理匯總了C#中System.Web.UI.WebControls.HyperLink.RenderBeginTag方法的典型用法代碼示例。如果您正苦於以下問題:C# HyperLink.RenderBeginTag方法的具體用法?C# HyperLink.RenderBeginTag怎麽用?C# HyperLink.RenderBeginTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Web.UI.WebControls.HyperLink
的用法示例。
在下文中一共展示了HyperLink.RenderBeginTag方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetDesignTimeHtml
public override string GetDesignTimeHtml()
{
AdRotator viewControl = (AdRotator) base.ViewControl;
StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);
DesignTimeHtmlTextWriter writer2 = new DesignTimeHtmlTextWriter(writer);
HyperLink link = new HyperLink {
ID = viewControl.ID,
NavigateUrl = "",
Target = viewControl.Target,
AccessKey = viewControl.AccessKey,
Enabled = viewControl.Enabled,
TabIndex = viewControl.TabIndex
};
link.Style.Value = viewControl.Style.Value;
link.RenderBeginTag(writer2);
Image image = new Image();
image.ApplyStyle(viewControl.ControlStyle);
image.SetDesignMode();
image.ImageUrl = "";
image.AlternateText = viewControl.ID;
image.ToolTip = viewControl.ToolTip;
image.RenderControl(writer2);
link.RenderEndTag(writer2);
return writer.ToString();
}
示例2: Render
protected override void Render (HtmlTextWriter writer)
{
HyperLink hLink = new HyperLink ();
Image adImage = new Image();
foreach (string current in Attributes.Keys)
hLink.Attributes [current] = Attributes [current];
if (ID != null && ID.Length > 0)
hLink.ID = ID;
hLink.Target = Target;
hLink.AccessKey = AccessKey;
hLink.Enabled = Enabled;
hLink.TabIndex = TabIndex;
if (navigateUrl != null && navigateUrl.Length != 0)
hLink.NavigateUrl = ResolveAdUrl (navigateUrl);
hLink.RenderBeginTag (writer);
if (ControlStyleCreated)
adImage.ApplyStyle(ControlStyle);
if(imageUrl!=null && imageUrl.Length > 0)
adImage.ImageUrl = ResolveAdUrl (imageUrl);
adImage.AlternateText = alternateText;
adImage.ToolTip = ToolTip;
adImage.RenderControl (writer);
hLink.RenderEndTag (writer);
}
示例3: RenderContents
/// <summary>
///
/// </summary>
/// <param name="writer"></param>
/// <author>
/// Created by Iulian Iuga; 30 December, 2002
/// </author>
protected void RenderContents( HtmlTextWriter writer )
{
TableRow _tr = new TableRow();
TableCell _td = new TableCell();
_tr.RenderBeginTag( writer );
// apply CssClass for current element
if( _element.TreeWeb.DefaultElementCssClass.Length > 0 )
_td.CssClass = _element.TreeWeb.DefaultElementCssClass;
if( _element.CssClass.Length > 0 )
_td.CssClass = _element.CssClass;
//_td.Style.Add( "display", "none" );
_td.Attributes.Add( "nowrap", "yes" );
_td.RenderBeginTag( writer );
// render a at the begining of each element
writer.Write( " " );
// render element indentation based on element level
string _indentation = "";
int nIndentationPerStep = _element.TreeWeb.Indentation;
for( int index = 0; index < (_element.Level * nIndentationPerStep); index++ )
_indentation += _indentationStep;
writer.Write( _indentation );
// render the expand/collapse link if the element has child elements and is expandable.
if( _element.HasElements )
{
HyperLink _link = new HyperLink();
Image _image = new Image();
if( _element.TreeWeb.Expandable && _element.Expandable )
{
if( _element.IsExpanded )
{
_link.Text = _expcol[1];
if( _element.TreeWeb.ExpandedElementImage.Length > 0 )
_image.ImageUrl = _element.TreeWeb.ExpandedElementImage;
}
else
{
_link.Text = _expcol[0];
if( _element.TreeWeb.CollapsedElementImage.Length > 0 )
_image.ImageUrl = _element.TreeWeb.CollapsedElementImage;
}
}
string scriptCode = "javascript:";
scriptCode += _element.TreeWeb.Page.GetPostBackEventReference( _element.TreeWeb, _element.ID );
_link.NavigateUrl = scriptCode;
if( _image.ImageUrl.Length > 0 )
{
_link.RenderBeginTag( writer );
_image.RenderControl( writer );
_link.RenderEndTag( writer );
}
else
_link.RenderControl( writer );
_image = null;
_link = null;
writer.Write( " " );
}
// render checkbox
if( _element.TreeWeb.CheckBoxes || _element.CheckBox )
{
CheckBox _checkbox = new CheckBox();
_checkbox.ID = _element.ID + TreeElement._separator + TreeElement._checkboxIDSufix;
_checkbox.RenderControl( writer );
_checkbox = null;
// write a non-breaking space before the element text
writer.Write( " " );
}
// render element's image if it has one
if( _element.ImageIndex > -1 )
{
ElementImage _elementImage = _element.TreeWeb.ImageList[_element.ImageIndex];
if( _elementImage != null )
{
Image _image = new Image();
_image.ImageUrl = _elementImage.ImageUrl;
_image.RenderControl( writer );
_image = null;
//.........這裏部分代碼省略.........
示例4: 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;
}
//.........這裏部分代碼省略.........
示例5: 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
}
//.........這裏部分代碼省略.........
示例6: RenderLink
private void RenderLink(HtmlTextWriter writer, AdCreatedEventArgs adArgs)
{
HyperLink link = new HyperLink {
NavigateUrl = adArgs.NavigateUrl,
Target = this.Target
};
if (base.HasAttributes)
{
foreach (string str in base.Attributes.Keys)
{
link.Attributes[str] = base.Attributes[str];
}
}
if (!string.IsNullOrEmpty(this.ID))
{
link.ID = this.ClientID;
}
if (!this.Enabled)
{
link.Enabled = false;
}
string str3 = (string) this.ViewState["AccessKey"];
if (!string.IsNullOrEmpty(str3))
{
link.AccessKey = str3;
}
object obj2 = this.ViewState["TabIndex"];
if (obj2 != null)
{
short num = (short) obj2;
if (num != 0)
{
link.TabIndex = num;
}
}
link.RenderBeginTag(writer);
Image image = new Image();
if (base.ControlStyleCreated)
{
image.ApplyStyle(base.ControlStyle);
}
string alternateText = adArgs.AlternateText;
if (!string.IsNullOrEmpty(alternateText))
{
image.AlternateText = alternateText;
}
else
{
IDictionary adProperties = adArgs.AdProperties;
string str5 = (this.AlternateTextField.Length != 0) ? this.AlternateTextField : "AlternateText";
string str6 = (adProperties == null) ? null : ((string) adProperties[str5]);
if ((str6 != null) && (str6.Length == 0))
{
image.GenerateEmptyAlternateText = true;
}
}
image.UrlResolved = true;
string imageUrl = adArgs.ImageUrl;
if (!string.IsNullOrEmpty(imageUrl))
{
image.ImageUrl = imageUrl;
}
if (adArgs.HasWidth)
{
image.ControlStyle.Width = adArgs.Width;
}
if (adArgs.HasHeight)
{
image.ControlStyle.Height = adArgs.Height;
}
string str8 = (string) this.ViewState["ToolTip"];
if (!string.IsNullOrEmpty(str8))
{
image.ToolTip = str8;
}
image.RenderControl(writer);
link.RenderEndTag(writer);
}
示例7: RenderExpandNodeIcon
/// <summary>
///
/// </summary>
/// <param name="writer"></param>
/// <remarks>
/// </remarks>
/// <history>
/// [jbrinkman] 5/6/2004 Created
/// [Jon Henning] 11/28/2005 Added iscrawler logic
/// </history>
protected void RenderExpandNodeIcon( HtmlTextWriter writer )
{
if( _Node.HasNodes )
{
HyperLink _link = new HyperLink();
Image _image = new Image();
if( _Node.IsExpanded || _Node.DNNTree.IsCrawler )
{
_link.Text = _expcol[1];
if( _Node.DNNTree.ExpandedNodeImage.Length > 0 )
{
_image.ImageUrl = _Node.DNNTree.ExpandedNodeImage;
}
}
else
{
_link.Text = _expcol[0];
if( _Node.DNNTree.CollapsedNodeImage.Length > 0 )
{
_image.ImageUrl = _Node.DNNTree.CollapsedNodeImage;
}
}
//If _Node.PopulateOnDemand Then 'handled in postback handler
// _link.NavigateUrl = ClientAPI.GetPostBackClientHyperlink(_Node.DNNTree, _Node.ID & ",OnDemand")
//Else
_link.NavigateUrl = ClientAPI.GetPostBackClientHyperlink( _Node.DNNTree, _Node.ID );
//End If
if( _image.ImageUrl.Length > 0 )
{
_link.RenderBeginTag( writer );
_image.RenderControl( writer );
_link.RenderEndTag( writer );
}
else
{
_link.RenderControl( writer );
}
_image = null;
_link = null;
}
else
{
RenderSpacer( writer, _Node.DNNTree.ExpandCollapseImageWidth );
}
writer.Write( " ", null );
}
示例8: RenderLink
private void RenderLink(HtmlTextWriter writer, AdCreatedEventArgs adArgs) {
Debug.Assert(writer != null);
Debug.Assert(adArgs != null);
HyperLink bannerLink = new HyperLink();
bannerLink.NavigateUrl = adArgs.NavigateUrl;
bannerLink.Target = Target;
if (HasAttributes) {
foreach(string key in Attributes.Keys) {
bannerLink.Attributes[key] = Attributes[key];
}
}
string id = ID;
if (!String.IsNullOrEmpty(id)) {
bannerLink.ID = ClientID;
}
if (!Enabled) {
bannerLink.Enabled = false;
}
// WebControl's properties use a private flag to determine if a
// property is set and does not return the value unless the flag is
// marked. So here we access those properites (inherited from WebControl)
// directly from the ViewState bag because if ViewState bag reference
// was copied to the helper class in the optimized case during the
// Initialize() method, the flags of the properties wouldn't be set
// in the helper class.
string accessKey = (string) ViewState["AccessKey"];
if (!String.IsNullOrEmpty(accessKey)) {
bannerLink.AccessKey = accessKey;
}
object o = ViewState["TabIndex"];
if (o != null) {
short tabIndex = (short) o;
if (tabIndex != (short) 0) {
bannerLink.TabIndex = tabIndex;
}
}
bannerLink.RenderBeginTag(writer);
// create inner Image
Image bannerImage = new Image();
// apply styles to image
if (ControlStyleCreated) {
bannerImage.ApplyStyle(ControlStyle);
}
string alternateText = adArgs.AlternateText;
if (!String.IsNullOrEmpty(alternateText)) {
bannerImage.AlternateText = alternateText;
}
else {
// 25914 Do not render empty 'alt' attribute if <AlternateText> tag is never specified
IDictionary adProps = adArgs.AdProperties;
string altTextKey = (AlternateTextField.Length != 0)
? AlternateTextField : AdCreatedEventArgs.AlternateTextElement;
string altText = (adProps == null) ? null : (string) adProps[altTextKey];
if (altText != null && altText.Length == 0) {
bannerImage.GenerateEmptyAlternateText = true;
}
}
// Perf work: AdRotator should have resolved the NavigateUrl and
// ImageUrl when assigning them and have UrlResolved set properly.
bannerImage.UrlResolved = true;
string imageUrl = adArgs.ImageUrl;
if (!String.IsNullOrEmpty(imageUrl)) {
bannerImage.ImageUrl = imageUrl;
}
if (adArgs.HasWidth) {
bannerImage.ControlStyle.Width = adArgs.Width;
}
if (adArgs.HasHeight) {
bannerImage.ControlStyle.Height = adArgs.Height;
}
string toolTip = (string) ViewState["ToolTip"];
if (!String.IsNullOrEmpty(toolTip)) {
bannerImage.ToolTip = toolTip;
}
bannerImage.RenderControl(writer);
bannerLink.RenderEndTag(writer);
}