How to get @Url.Action url in a separate script file?
By FoxLearn 2/16/2024 9:31:22 AM 58
This post shows you How to get @Url.Action url in a separate script file
@section Scripts{ <script type="text/javascript"> var app = app || {}; app.Urls = app.Urls || {}; app.Urls.baseUrl = '@Url.Content("~")'; app.Urls.addEditUrl = '@Url.Action("AddEdit")'; app.Urls.getListUrl = '@Url.Action("GetList")'; </script> <script src="~/js/external.js"></script> }
In your javascript file, you can easily get url from @Url.Action in ASP.NET or ASP.NET Core as shown below.
var url = app.Urls.getListUrl
I hope you you can solve the problem jquery url action in external js file
- How to Add Active Navigation Class Based on URL
- How to Display popup message in Javascript
- How to Show message instead of alert
- How to fix 'Uncaught TypeError: Cannot read property 'fn' of undefined'
- How to Format numbers with commas in Javascript
- How to format number with commas and decimal in Javascript
- How to Pass string parameter in an onclick function
- How to use sweetalert2
Categories
Popular Posts
Visual Studio: Auto increment version
04/01/2024
What is ARM architecture?
04/01/2024
What Are RESTful Web Services?
02/19/2024