本文整理汇总了C#中System.Web.Mvc.HtmlHelper.StyleSheet方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlHelper.StyleSheet方法的具体用法?C# HtmlHelper.StyleSheet怎么用?C# HtmlHelper.StyleSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.HtmlHelper
的用法示例。
在下文中一共展示了HtmlHelper.StyleSheet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterStylesheet_TwoTimes_NoDuplicateRegistrations
public void RegisterStylesheet_TwoTimes_NoDuplicateRegistrations()
{
var dummyHttpContext = new DummyHttpContext();
var dummyViewContext = new ViewContext();
dummyViewContext.HttpContext = dummyHttpContext;
var dummyViewDataContainer = (IViewDataContainer)new ViewPage();
var htmlHelper = new System.Web.Mvc.HtmlHelper(dummyViewContext, dummyViewDataContainer);
var stylesheet = "Mvc/Styles/Designer/modal-dialog.css";
string expected1 = string.Format(System.Globalization.CultureInfo.InvariantCulture, "<link href=\"{0}\" rel=\"stylesheet\" type=\"text/css\" />", stylesheet);
string result1 = htmlHelper.StyleSheet(stylesheet).ToString();
Assert.AreEqual(expected1, result1);
MvcHtmlString expected2 = MvcHtmlString.Empty;
MvcHtmlString result2 = htmlHelper.StyleSheet(stylesheet);
Assert.AreEqual(expected2, result2);
}
示例2: RegisterStylesheet_TwoTimes_ExceptionIsThrown
public void RegisterStylesheet_TwoTimes_ExceptionIsThrown()
{
var dummyHttpContext = new DummyHttpContext();
var dummyViewContext = new ViewContext();
dummyViewContext.HttpContext = dummyHttpContext;
var dummyViewDataContainer = (IViewDataContainer)new ViewPage();
var htmlHelper = new System.Web.Mvc.HtmlHelper(dummyViewContext, dummyViewDataContainer);
var stylesheet = "Mvc/Styles/Designer/modal-dialog.css";
string expected = string.Format(System.Globalization.CultureInfo.InvariantCulture, "<link href=\"{0}\" rel=\"stylesheet\" type=\"text/css\" />", stylesheet);
string result = htmlHelper.StyleSheet(stylesheet, null, throwException: true).ToString();
Assert.AreEqual(expected, result);
htmlHelper.StyleSheet(stylesheet, null, throwException: true);
}