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


C# HtmlLink.RenderControl方法代码示例

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


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

示例1: AddToClientScriptManager

 /// <summary>
 /// Adds to client script manager.
 /// </summary>
 /// <param name="page">The page.</param>
 /// <param name="link">The link.</param>
 private static void AddToClientScriptManager(Page page, HtmlLink link)
 {
     HtmlTextWriter writer = new HtmlTextWriter(new StringWriter(new StringBuilder()));
       link.RenderControl(writer);
       page.ClientScript.RegisterClientScriptBlock(typeof(Page),
     writer.InnerWriter.ToString(), writer.InnerWriter.ToString());
 }
开发者ID:Refactored,项目名称:SitecoreCalendarModule,代码行数:12,代码来源:PageExtensions.cs

示例2: IncludeCSS

 /// <summary>
 /// Includes an html markup like <link rel=Stylesheet type=text/css href=[YOUR_HREF] />
 /// </summary>
 /// <param name="htmlHelper"></param>
 /// <param name="path"></param>
 /// <param name="includeVersionBasedOnLastModifiedDate">adding the query param "v" = [yyyyMMddHHmmss] based on file last modified date</param>
 /// <returns></returns>
 public static IHtmlString IncludeCSS(this HtmlHelper htmlHelper, string path, bool includeVersionBasedOnLastModifiedDate = true)
 {
     string physicalPath = htmlHelper.ViewContext.HttpContext.Server.MapPath(path);
     var fileInfo = new FileInfo(physicalPath);
     if (!fileInfo.Exists) return new RawHtmlString(String.Empty);
     var lastModifiedDate = fileInfo.LastWriteTime;
     var sb = new StringBuilder();
     using (var textWriter = new StringWriter(sb))
     {
         using (var htmlWriter = new HtmlTextWriter(textWriter))
         {
             var htmlLink = new HtmlLink();
             htmlLink.Attributes["rel"] = "Stylesheet";
             htmlLink.Href = String.Format("{0}?v={1:yyyyMMddHHmmss}", VirtualPathUtility.ToAbsolute(path), lastModifiedDate);
             htmlLink.Attributes["type"] = "text/css";
             htmlLink.RenderControl(htmlWriter);
         }
     }
     return new RawHtmlString(sb.ToString());
 }
开发者ID:xunter,项目名称:PavelNazarov.Common,代码行数:27,代码来源:HtmlIncludesExtensions.cs


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