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