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


C# HtmlHelper.Script方法代码示例

本文整理汇总了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);
        }
开发者ID:jeffpignataro,项目名称:feather,代码行数:15,代码来源:ResourceHelperTests.cs

示例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());
            }
        }
开发者ID:RifasRazick,项目名称:feather,代码行数:18,代码来源:DummyScriptController.cs

示例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);
        }
开发者ID:RifasRazick,项目名称:feather,代码行数:18,代码来源:ResourceHelperTests.cs

示例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());
        }
开发者ID:jeffpignataro,项目名称:feather,代码行数:10,代码来源:DummyScriptController.cs


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