ASP.NET导入JavaScript文件
我正在尝试将自定义javascript文件导入asp.net webforms。Visual Studio在主体内部生成的样板导入块如下所示:ASP.NET导入JavaScript文件,javascript,c#,asp.net,visual-studio,webforms,Javascript,C#,Asp.net,Visual Studio,Webforms,我正在尝试将自定义javascript文件导入asp.net webforms。Visual Studio在主体内部生成的样板导入块如下所示: <asp:ScriptManager runat="server"> <Scripts> <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwli
<asp:ScriptManager runat="server">
<Scripts>
<%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="bootstrap" />
<asp:ScriptReference Name="respond" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>
我试图将此添加到我的BundleConfig.cs
:
bundles.Add(new ScriptBundle("~/bundles/Site").Include(
"~/Scripts/Site.js"));
但这并没有改变任何事情。知道如何导入我的js文件吗?1。只需使用path即可,无需任何额外代码
<asp:ScriptReference Path="Scripts/Site.js"/>
网站管理员
将其包含在站点主目录中
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/Site") %>
</asp:PlaceHolder>
4.直接参考脚本
<script src="Scripts/Site.js" type="text/javascript"></script>
1.只需使用path,它就可以工作,不需要任何额外的代码
<asp:ScriptReference Path="Scripts/Site.js"/>
网站管理员
将其包含在站点主目录中
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/Site") %>
</asp:PlaceHolder>
4.直接参考脚本
<script src="Scripts/Site.js" type="text/javascript"></script>
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/Site") %>
</asp:PlaceHolder>
<script src="Scripts/Site.js" type="text/javascript"></script>