Использование ScriptManager для добавления ссылок javascript на Site.Master

Я недавно получил html и ресурсы от моей компании для их веб-стандартов. У меня есть существующее веб-приложение asp.net, которое я создал с использованием шаблона по умолчанию в Visual Studio 2015. Я неловко работаю над тем, чтобы увидеть, смогу ли я применить эти изменения к Site.Master, и первое, что я пытаюсь сделать нужно добавить файлы javascript через asp:ScriptReference следующим образом.

<asp:ScriptManager ID="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--%>
            <asp:ScriptReference Name="angular.min.js" Path="~/Scripts/angular.min.js"/>
            <asp:ScriptReference Name="default.min.js" Path="~/Scripts/default.min.js"/>
            <asp:ScriptReference Name="forms.js" Path="~/Scripts/forms.js"/>
            <asp:ScriptReference Name="libraries.js" Path="~/Scripts/libraries.js"/>
        </Scripts>
    </asp:ScriptManager>

Я не уверен, чем отличаются сценарии фреймворка и сценарии сайта, но те, которые я добавил, находятся в разделе «Сценарии сайта».

Я также скопировал файлы .js в папку сценариев, где они должны находиться, поэтому все пути указаны правильно.

Однако я получаю следующую ошибку, когда публикую и открываю свое приложение в браузере.

The assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not contain a Web resource that has the name 'angular.min.js'. Make sure that the resource name is spelled correctly.

Это приводит меня к файлу AssemblyInfo.cs, который для меня не имеет смысла. Он содержит только следующее:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WebApplication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WebApplication")]
[assembly: AssemblyCopyright("Copyright ©  2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e0ca37b5-d082-45bf-a409-4d03cd60fc61")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

А также файл Web.Config, где информация о зависимых сборках, кажется, определена или что-то в этом роде.

Кажется, я здесь не в своей тарелке, это мой первый опыт работы с веб-приложениями в asp.net. Мне удалось выяснить, как начать работу в представлении дизайна, и мне удалось выполнить многое из того, что я хочу сделать функционально, с помощью кода программной части С#. Однако когда дело доходит до AssemblyInfo и Web.Config, то, что они из себя представляют и как их использовать, не имеет большого смысла, учитывая, что моя система отсчета с веб-интерфейсами была html, jquery и немного css.

Может ли кто-нибудь объяснить мне хотя бы, как успешно добавить больше скриптов, и, возможно, также как успешно применить css и другие полезные советы для настройки внешнего вида шаблона приложения? Большое спасибо заранее.


person David    schedule 25.01.2017    source источник


Ответы (1)


Добавление ресурсов javascript в

<%--Site Scripts--%>

в блоке ScriptManager является соглашением, которое следует использовать только для информации.

Если вы не используете свойство ScriptResourceMapping ScriptManager в ScriptResourceDefinition, тег «Name» следует оставить пустым.

Вместо этого они должны работать:

<%--Site Scripts--%>
<asp:ScriptReference Path="~/Scripts/angular.min.js"/>
<asp:ScriptReference Path="~/Scripts/default.min.js"/>
<asp:ScriptReference Path="~/Scripts/forms.js"/>
<asp:ScriptReference Path="~/Scripts/libraries.js"/>

Обратите внимание, что я удалил «Имя» и включил только «Путь».

person Walker    schedule 23.04.2019