本文整理汇总了C#中System.Web.UI.WebControls.HyperLink.RenderControl方法的典型用法代码示例。如果您正苦于以下问题:C# HyperLink.RenderControl方法的具体用法?C# HyperLink.RenderControl怎么用?C# HyperLink.RenderControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.HyperLink
的用法示例。
在下文中一共展示了HyperLink.RenderControl方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createCellContents
private string createCellContents(string directURL, string queryStringKey, string queryStringValue, Transcoder transcoder)
{
StringBuilder output = new StringBuilder();
HtmlTextWriter writer = new HtmlTextWriter(new System.IO.StringWriter(output));
// direct
HyperLink direct = new HyperLink();
direct.NavigateUrl = directURL;
direct.Text = "Direct";
direct.RenderControl(writer);
// dynamic stream types
Dictionary<string, string> pages = new Dictionary<string, string>();
pages["VLC"] = "VLC.aspx";
pages["M3U"] = "Playlist.aspx";
pages["HTML5"] = "HTML5.aspx";
// and render them
int i = 1;
foreach (KeyValuePair<string, string> page in pages) {
HyperLink link = new HyperLink();
NameValueCollection queryString = HttpUtility.ParseQueryString(string.Empty);
queryString["transcoder"] = transcoder.Id.ToString();
queryString[queryStringKey] = queryStringValue;
link.NavigateUrl = page.Value + "?" + queryString.ToString();
link.Text = page.Key;
output.Append(i % 2 == 1 ? " - " : "<br />");
link.RenderControl(writer);
i++;
}
return output.ToString();
}
示例2: RenderContents
protected override void RenderContents(HtmlTextWriter writer)
{
var contentPath = string.Empty;
var currentUrlList = GetSiteUrlList(ref contentPath);
var protocol = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Scheme);
#region template
if (UseBrowseTemplate)
{
Try2AddUrlLinks(contentPath, currentUrlList, protocol);
base.RenderContents(writer);
return;
}
if (UseEditTemplate)
{
Try2AddUrlLinks(contentPath, currentUrlList, protocol);
base.RenderContents(writer);
return;
}
if (UseInlineEditTemplate)
{
Try2AddUrlLinks(contentPath, currentUrlList, protocol);
base.RenderContents(writer);
return;
}
#endregion
foreach (var siteUrl in currentUrlList)
{
var url = string.Concat(protocol, siteUrl, contentPath);
var link = new System.Web.UI.WebControls.HyperLink();
link.NavigateUrl = url;
link.Text = url;
link.Target = "new";
link.CssClass = this.CssClass;
link.RenderControl(writer);
writer.WriteBreak();
}
}
示例3: RenderNodeText
/// -----------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="writer"></param>
/// <remarks>
/// </remarks>
/// <history>
/// [jhenning] 9/21/2005 Created
/// </history>
/// -----------------------------------------------------------------------------
protected void RenderNodeText(HtmlTextWriter writer)
{
HyperLink _link = new HyperLink();
string strJS = "";
bool blnNormalLink = false;
_link.Text = m_objNode.Text;
if (!String.IsNullOrEmpty(m_objNode.JSFunction))
{
if (m_objNode.JSFunction.EndsWith(";") == false) strJS += m_objNode.JSFunction + ";";
}
else if (!String.IsNullOrEmpty(m_objNode.DNNMenu.JSFunction)) {
if (m_objNode.DNNMenu.JSFunction.EndsWith(";") == false) strJS += m_objNode.DNNMenu.JSFunction + ";";
}
if (m_objNode.Enabled)
{
switch (m_objNode.ClickAction) {
case eClickAction.PostBack:
case eClickAction.Expand:
case eClickAction.None:
//none included since downlevel
if (!String.IsNullOrEmpty(strJS)) strJS = "if (eval(\"" + strJS.Replace("\"", "\"\"") + "\") != false) ";
strJS += m_objNode.DNNMenu.Page.GetPostBackEventReference(m_objNode.DNNMenu, m_objNode.ID + ClientAPI.COLUMN_DELIMITER + "Click");
break;
case eClickAction.Navigate:
if (!String.IsNullOrEmpty(strJS)) strJS = "if (eval(\"" + strJS.Replace("\"", "\"\"") + "\") != false) ";
if (!String.IsNullOrEmpty(m_objNode.DNNMenu.Target))
{
strJS += "window.frames." + m_objNode.DNNMenu.Target + ".location.href='" + m_objNode.NavigateURL + "'; void(0);";
//FOR SOME REASON THIS DOESNT WORK UNLESS WE HAVE CODE AFTER THE SETTING OF THE HREF...
}
else
{
if (String.IsNullOrEmpty(strJS))
{
blnNormalLink = true;
}
else
{
strJS += "window.location.href='" + m_objNode.NavigateURL + "';"
;
}
}
break;
}
if (blnNormalLink)
{
_link.NavigateUrl = m_objNode.NavigateURL;
}
else
{
_link.NavigateUrl = "javascript:" + strJS;
}
}
if (!String.IsNullOrEmpty(m_objNode.ToolTip))
{
_link.ToolTip = m_objNode.ToolTip;
}
string sCSS = GetNodeCss(m_objNode);
if (!String.IsNullOrEmpty(sCSS)) _link.CssClass = sCSS;
_link.RenderControl(writer);
}
示例4: 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;
//.........这里部分代码省略.........
示例5: RenderContents
protected override void RenderContents(HtmlTextWriter writer) {
Menu owner = Control;
int position = 0;
if (_titleItem != null) {
if (_titleItem.Depth + 1 >= owner.MaximumDepth) {
throw new InvalidOperationException(SR.GetString(SR.Menu_InvalidDepth));
}
if (!_titleItem.IsEnabled) {
throw new InvalidOperationException(SR.GetString(SR.Menu_InvalidNavigation));
}
RenderItem(writer, _titleItem, position++);
foreach (MenuItem child in _titleItem.ChildItems) {
RenderItem(writer, child, position++);
}
if (PageAdapter != null) {
PageAdapter.RenderPostBackEvent(writer,
owner.UniqueID,
"u",
SR.GetString(SR.MenuAdapter_Up),
SR.GetString(SR.MenuAdapter_UpOneLevel));
}
else {
HyperLink link = new HyperLink();
link.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(owner, "u");
link.Text = SR.GetString(SR.MenuAdapter_UpOneLevel);
link.Page = Page;
link.RenderControl(writer);
}
return;
}
else {
position = 1;
}
_path = null;
foreach(MenuItem child in owner.Items) {
RenderItem(writer, child, position++);
if (owner.StaticDisplayLevels > 1 && child.ChildItems.Count > 0) {
RenderContentsRecursive(writer, child, 1, owner.StaticDisplayLevels);
}
}
}
示例6: RenderBeginTag
protected override void RenderBeginTag(HtmlTextWriter writer) {
Menu owner = Control;
// skip link
if (owner.SkipLinkText.Length != 0) {
HyperLink skipLink = new HyperLink();
skipLink.NavigateUrl = '#' + owner.ClientID + "_SkipLink";
skipLink.ImageUrl = owner.SpacerImageUrl;
skipLink.Text = owner.SkipLinkText;
skipLink.Height = Unit.Pixel(1);
skipLink.Width = Unit.Pixel(1);
skipLink.Page = Page;
skipLink.RenderControl(writer);
}
_menuPanel = new Panel();
_menuPanel.ID = owner.UniqueID;
_menuPanel.Page = Page;
// Determine root menu style
MenuItem titleItem;
if (_path != null) {
titleItem = owner.Items.FindItem(_path.Split(TreeView.InternalPathSeparator), 0);
_titleItem = titleItem;
}
else {
titleItem = owner.RootItem;
}
SubMenuStyle rootMenuStyle = owner.GetSubMenuStyle(titleItem);
if (!rootMenuStyle.IsEmpty) {
if (Page != null && Page.SupportsStyleSheets) {
string styleClass = owner.GetSubMenuCssClassName(titleItem);
if (styleClass.Trim().Length > 0) {
_menuPanel.CssClass = styleClass;
}
}
else {
_menuPanel.ApplyStyle(rootMenuStyle);
}
}
_menuPanel.Width = owner.Width;
_menuPanel.Height = owner.Height;
_menuPanel.Enabled = owner.IsEnabled;
_menuPanel.RenderBeginTag(writer);
}
示例7: RenderItem
protected void RenderItem(HtmlTextWriter writer, SiteMapNode node, int count)
{
var currentNode = SiteMapBase.GetCurrentProvider().CurrentNode as PageSiteNode;
var pageNode = (PageSiteNode)node;
if (pageNode.ShowInNavigation == true || ShowAll == true)
{
HyperLink hyp = null;
/* Create and Render Link */
hyp = new HyperLink();
if ((pageNode.IsGroupPage) && pageNode.HasChildNodes && (OverrideGroup == true))
{
hyp.NavigateUrl = ResolveUrl(node.ChildNodes[0].Url);
}
else
{
hyp.NavigateUrl = ResolveUrl(node.Url);
}
hyp.Text = node.Title;
string classes = "";
if (!this.IsDesignMode() && node != null)
{
if (currentNode != null)
{
if (currentNode.PageId == pageNode.PageId)
{
classes += " active";
}
}
if (node.ChildNodes.Count > 0)
{
classes += " parent";
}
if (node.PreviousSibling == null)
{
classes += " first";
}
if (node.NextSibling == null)
{
classes += " last";
}
if (UniqueClasses)
{
classes += " " + pageNode.UrlName.ToLower();
}
if (classes.Length > 0)
{
writer.AddAttribute(HtmlTextWriterAttribute.Class, classes.Trim());
}
}
writer.RenderBeginTag(HtmlTextWriterTag.Li);
hyp.Text = ItemTemplate.Replace("[[link]]", hyp.Text);
hyp.RenderControl(writer);
if (node.ChildNodes.Count > 0 && (count < LayerLimit || LayerLimit < 1))
{
writer.RenderBeginTag(HtmlTextWriterTag.Ul);
foreach (SiteMapNode m in node.ChildNodes)
{
this.RenderItem(writer, m, count++);
}
writer.RenderEndTag();
}
writer.RenderEndTag();
}
}
示例8: RenderNodeText
/// <summary>
///
/// </summary>
/// <param name="writer"></param>
/// <remarks>
/// </remarks>
/// <history>
/// [jbrinkman] 5/6/2004 Created
/// </history>
protected void RenderNodeText( HtmlTextWriter writer )
{
//Dim _label As Label = New Label
HyperLink _link = new HyperLink();
string strJS = "";
//_label.Text = _Node.Text
_link.Text = _Node.Text;
if( _Node.JSFunction.Length > 0 )
{
if( _Node.JSFunction.EndsWith( ";" ) == false )
{
_Node.JSFunction += ";";
}
strJS += _Node.JSFunction;
}
else if( _Node.DNNTree.JSFunction.Length > 0 )
{
if( _Node.DNNTree.JSFunction.EndsWith( ";" ) == false )
{
_Node.DNNTree.JSFunction += ";";
}
strJS += _Node.DNNTree.JSFunction;
}
if( _Node.Enabled )
{
switch( _Node.ClickAction )
{
case eClickAction.PostBack:
if( strJS.Length > 0 )
{
strJS = "if (eval(\"" + strJS.Replace( "\"", "\"\"" ) + "\") != false) ";
}
strJS += ClientAPI.GetPostBackClientHyperlink( _Node.DNNTree, _Node.ID + ClientAPI.COLUMN_DELIMITER + "Click" ).Replace( "javascript:", "" );
break;
case eClickAction.Expand:
if( strJS.Length > 0 )
{
strJS = "if (eval(\"" + strJS.Replace( "\"", "\"\"" ) + "\") != false) ";
}
strJS += ClientAPI.GetPostBackClientHyperlink( _Node.DNNTree, _Node.ID + ClientAPI.COLUMN_DELIMITER + "Click" ).Replace( "javascript:", "" );
break;
case eClickAction.Navigate:
if( strJS.Length > 0 )
{
strJS = "if (eval(\"" + strJS.Replace( "\"", "\"\"" ) + "\") != false) ";
}
if( _Node.DNNTree.Target.Length > 0 )
{
strJS += "window.frames." + _Node.DNNTree.Target + ".location.href='" + _Node.NavigateUrl + "'; void(0);"; //FOR SOME REASON THIS DOESNT WORK UNLESS WE HAVE CODE AFTER THE SETTING OF THE HREF...
}
else
{
strJS += "window.location.href='" + _Node.NavigateUrl + "';";
}
break;
}
_link.NavigateUrl = "javascript:" + strJS;
}
if( _Node.ToolTip.Length > 0 )
{
//_label.ToolTip = _Node.ToolTip
_link.ToolTip = _Node.ToolTip;
}
//_label.CssClass = "NodeText"
//_label.RenderControl(writer)
string sCSS = GetNodeCss( _Node );
if( sCSS.Length > 0 )
{
_link.CssClass = sCSS;
}
//If _Node.Selected Then
// If Len(_Node.DNNTree.DefaultNodeCssClassSelected) > 0 Then _link.CssClass = _Node.DNNTree.DefaultNodeCssClassSelected
//Else
// _link.CssClass = _Node.CSSClass
//End If
_link.RenderControl( writer );
}
示例9: 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 );
}
示例10: RenderContents
protected override void RenderContents( HtmlTextWriter writer )
{
var text = Text;
if ( !string.IsNullOrEmpty( text ) )
{
const string startToken = @"{0}";
const string endToken = @"{1}";
string beforeText;
string hyperlinkText;
string afterText;
if ( text.Contains( startToken ) && text.Contains( endToken ) )
{
beforeText = text.Substring( 0, text.IndexOf( startToken ) );
hyperlinkText = text.Substring(
text.IndexOf( startToken ) + startToken.Length,
text.IndexOf( endToken ) - (text.IndexOf( startToken ) + startToken.Length) );
afterText = text.Substring( text.IndexOf( endToken ) + endToken.Length );
}
else if ( text.Contains( startToken ) )
{
beforeText = text.Substring( 0, text.IndexOf( startToken ) );
hyperlinkText = text.Substring( text.IndexOf( startToken ) + startToken.Length );
afterText = null;
}
else if ( text.Contains( endToken ) )
{
beforeText = null;
hyperlinkText = text.Substring( 0, text.IndexOf( endToken ) );
afterText = text.Substring( text.IndexOf( endToken ) + endToken.Length );
}
else
{
beforeText = text;
hyperlinkText = null;
afterText = null;
}
// --
if ( !string.IsNullOrEmpty( beforeText ) )
{
writer.WriteEncodedText( beforeText );
}
if ( !string.IsNullOrEmpty( hyperlinkText ) )
{
var hyperLink =
new HyperLink
{
Text = hyperlinkText,
NavigateUrl = NavigateUrl,
Target = Target,
ToolTip = ToolTip,
CssClass = CssClass,
ImageUrl = ImageUrl,
SkinID = SkinID
};
hyperLink.RenderControl( writer );
}
if ( !string.IsNullOrEmpty( afterText ) )
{
writer.WriteEncodedText( afterText );
}
}
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetMember_Info();
BLL.News b_News = new BLL.News();
Entity.News[] e_News;
e_News = b_News.Select_News(1, g_LanguageID, 5, 1);
if (e_News != null)
{
foreach (Entity.News o_News in e_News)
{
HyperLink o_HyperLink = new HyperLink();
o_HyperLink.NavigateUrl = "News_Detail.aspx?News_ID=" + o_News.News_ID.ToString();
if (o_News.News_Title.Length > 24)
o_HyperLink.Text = o_News.News_Title.Substring(0, 24);
else
o_HyperLink.Text = o_News.News_Title;
o_HyperLink.CssClass = "nav9";
StringBuilder o_StringBuilder = new StringBuilder();
StringWriter o_StringWriter = new StringWriter(o_StringBuilder);
HtmlTextWriter o_HtmlTextWriter = new HtmlTextWriter(o_StringWriter);
o_HyperLink.RenderControl(o_HtmlTextWriter);
News_ClassID_1_Controls.InnerHtml += "<li>" + o_StringBuilder.ToString() + " " + o_News.News_AddTime.ToShortDateString() + "</li>";
}
}
else
News_ClassID_1_More.Visible = false;
e_News = b_News.Select_News(2, g_LanguageID, 5, 1);
if (e_News != null)
{
foreach (Entity.News o_News in e_News)
{
HyperLink o_HyperLink = new HyperLink();
o_HyperLink.NavigateUrl = "News_Detail.aspx?News_ID=" + o_News.News_ID.ToString();
if (o_News.News_Title.Length > 24)
o_HyperLink.Text = o_News.News_Title.Substring(0, 24);
else
o_HyperLink.Text = o_News.News_Title;
o_HyperLink.CssClass = "nav9";
StringBuilder o_StringBuilder = new StringBuilder();
StringWriter o_StringWriter = new StringWriter(o_StringBuilder);
HtmlTextWriter o_HtmlTextWriter = new HtmlTextWriter(o_StringWriter);
o_HyperLink.RenderControl(o_HtmlTextWriter);
News_ClassID_2_Controls.InnerHtml += "<li>" + o_StringBuilder.ToString() + " " + o_News.News_AddTime.ToShortDateString() + "</li>";
}
}
else
News_ClassID_2_More.Visible = false;
}
}