You can reference the scripts from the following:
You can reference the scripts inside the template that your pages are based on.
For example, if the layout file that your pages are based on is named RootLayout.chtml, inside it you can reference a script in the following way:
RootLayout.chtml
You can reference your scripts directly in the widget template.
For example, if your widget is named MyWidget, you can reference a script in its Default.cshtml file in the following way:
MyWidget
Default.cshtml
NOTE: If you do not add the TagHelper attribute to the widget template, the section-name attribute will not work.
TagHelper
For example, the section-name=”Top” attribute instructs the Renderer to include your file either at the start of the body tag or, in case section-name=”Bottom”, before the closing body tag. For this attribute to work, you must include the tag helper references in your .cshtml.
section-name=”Top”
body
section-name=”Bottom”
.cshtml
You have the following options:
If you are building a standalone website, you can place the scripts in the standard wwwroot folder and you can reference them from there, as you would do in any standard .NET Core application. For more information, see Microsoft documentation for Static files in ASP.NET Core.
wwwroot
If you are building a widget as a class library that must be self-contained in a single assembly, you must place these client-side resources in the assembly, as embedded resources. Place the scripts in a separate folder in your project, called Scripts. Reference the script files in the .csproj file. For example, add the following: <embeddedresource include="Web\UI\Scripts\bootstrap.js"></embeddedresource>
Scripts
.csproj
<embeddedresource include="Web\UI\Scripts\bootstrap.js"></embeddedresource>
call-to-action
Progress.Sitefinity.AspNetCore.Widgets
The reference is using the section-name attribute, but it also includes the assembly-ref attribute, which points to the name of the assembly, where this file is placed as an embedded resource.
section-name
assembly-ref
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important