Click here to Skip to main content
15,565,950 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Problem with jQuery and autocomplete Pin
Member 1299665513-Jan-21 6:23
Member 1299665513-Jan-21 6:23 
GeneralRe: Problem with jQuery and autocomplete Pin
Richard Deeming13-Jan-21 7:20
mveRichard Deeming13-Jan-21 7:20 
Well, it does matter which approach you use - the @Scripts.Render approach won't work in ASP.NET Core / .NET 5, and the asp-append-version approach won't work properly in MVC5. Smile | :)

(To be precise, the asp-* attributes will be sent as-is in the rendered HTML, and won't have the expected effect in MVC5.)

If you're using MVC5, stick to the @Scripts.Render approach for your bundles, and remove the asp-* attributes from your <script> tags:

Layout:
Razor
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
<script src="~/js/site.min.js"></script>
@RenderSection("scripts", required: false)
View:
Razor
@section scripts {
    <script src="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/jquery-ui.min.js"></script>
    <link href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/themes/blitzer/jquery-ui.css" rel="stylesheet" />
    <script src="~/Scripts/selectAuthor.js"></script>
}


If you're using ASP.NET Core or .NET 5, use the asp-* attributes instead:

Layout:
Razor
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js"
        asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
        asp-fallback-test="window.jQuery"
        crossorigin="anonymous"
        integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
        asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
        asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
        crossorigin="anonymous"
        integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
</script>
<script src="~/js/site.min.js" asp-append-version="true"></script>
@RenderSection("scripts", required: false)
View:
Razor
@section scripts {
    <script src="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/jquery-ui.min.js"></script>
    <link href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/themes/blitzer/jquery-ui.css" rel="stylesheet" />
    <script src="~/Scripts/selectAuthor.js" asp-append-version="true"></script>
}


Either way, make sure you only include each library once in the page, and that you include them in the correct order. Check the "view source" option in your browser to view the rendered output to make sure it's doing what you expect.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Problem with jQuery and autocomplete Pin
Member 1299665513-Jan-21 7:21
Member 1299665513-Jan-21 7:21 
GeneralRe: Problem with jQuery and autocomplete Pin
Member 1299665513-Jan-21 8:01
Member 1299665513-Jan-21 8:01 
GeneralRe: Problem with jQuery and autocomplete Pin
Richard Deeming13-Jan-21 23:14
mveRichard Deeming13-Jan-21 23:14 
QuestionI have created housie game page, but it is loading slow. Pin
Member 150388166-Jan-21 1:04
Member 150388166-Jan-21 1:04 
AnswerRe: I have created housie game page, but it is loading slow. Pin
thatraja8-Jan-21 6:12
professionalthatraja8-Jan-21 6:12 
Questionhow to code following vb code to asp.net code Pin
Asanka Prabath1-Jan-21 20:07
Asanka Prabath1-Jan-21 20:07 
AnswerRe: how to code following vb code to asp.net code Pin
Mycroft Holmes2-Jan-21 21:03
professionalMycroft Holmes2-Jan-21 21:03 
AnswerRe: how to code following vb code to asp.net code Pin
Richard Deeming5-Jan-21 0:04
mveRichard Deeming5-Jan-21 0:04 
QuestionUnable to read from web.config Pin
samflex11-Dec-20 8:35
samflex11-Dec-20 8:35 
AnswerRe: Unable to read from web.config Pin
Richard MacCutchan11-Dec-20 8:42
mveRichard MacCutchan11-Dec-20 8:42 
GeneralRe: Unable to read from web.config Pin
samflex11-Dec-20 10:02
samflex11-Dec-20 10:02 
GeneralRe: Unable to read from web.config Pin
Richard MacCutchan11-Dec-20 23:20
mveRichard MacCutchan11-Dec-20 23:20 
GeneralRe: Unable to read from web.config Pin
samflex12-Dec-20 5:16
samflex12-Dec-20 5:16 
QuestionServer not recognizing AD info (SOLVED) Pin
samflex10-Dec-20 11:42
samflex10-Dec-20 11:42 
AnswerRe: Server not recognizing AD info Pin
Richard Deeming11-Dec-20 1:25
mveRichard Deeming11-Dec-20 1:25 
GeneralRe: Server not recognizing AD info Pin
samflex11-Dec-20 4:20
samflex11-Dec-20 4:20 
GeneralRe: Server not recognizing AD info Pin
Richard Deeming11-Dec-20 4:29
mveRichard Deeming11-Dec-20 4:29 
GeneralRe: Server not recognizing AD info Pin
samflex11-Dec-20 8:12
samflex11-Dec-20 8:12 
QuestionSSL Certificate problem with Local IIS, ADFS and Visual Studio Pin
Super Lloyd9-Dec-20 16:54
Super Lloyd9-Dec-20 16:54 
Questionpass the id to the modal Pin
Member 149089649-Nov-20 9:42
Member 149089649-Nov-20 9:42 
AnswerRe: pass the id to the modal Pin
Richard Deeming9-Nov-20 23:02
mveRichard Deeming9-Nov-20 23:02 
QuestionASP.NET Code with Azure AD Authentication Not working in Chrome and Edge Pin
Member 111541884-Nov-20 5:51
Member 111541884-Nov-20 5:51 
AnswerRe: ASP.NET Code with Azure AD Authentication Not working in Chrome and Edge Pin
Richard MacCutchan4-Nov-20 22:46
mveRichard MacCutchan4-Nov-20 22:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.