JavaScript Using Javascript files from a Class Library in an ASP.NET MVC project javascript using files,using multiple javascript files,using javascript files

Say I have a Class Library containing a HelloWorld.js file.

This file contains a couple javascript functions, like say:

function Hello_alert() {
   alert("Hello World!!");
}

and

function Hello_console() {
   console.log("Hello World!!");
}

I want to make so I can access the functions inside the HelloWorld.js file individually, on an ASP.NET MVC page, say, the Index.cshtml inside the Home folder. (Failing that, I'd be happy just accessing the .js file at all.)

I have already changed the .js as EmbeddedResource and added it to the Assembly as such:

[assembly: WebResource("JSLibrary.Scriptss.HelloWorld.js", "application/x-javascript")]

; referenced the DLL on my MVC project, and the DLL namespace shows up on Intellisense so I'm guessing it's linked right.

Now, I've been googling incessantly the whole day, and I've found a solution that kinda does what I need, but it's for Web Forms, using Page.ClientScript to register the scripts into the page itself, which allows one to call the functions inside the .js file on that page. This is pretty much what I'm trying to do, except I need it in MVC, which doesn't use the "Page" class like that.

The closes equivalent I've found has something to do with bundles, but I couldn't find any tutorials that I could viably follow.

So again, my question is, how do I somehow register Javascript files from a DLL in order for me to be able to call them from an ASP.NET MVC project?

--------Update:---------

Following the tutorial I linked above, my DLL has a class with a method that is used to register the scripts in a Script Manager, that it receives as a parameter. Like so

public static void includeHelloWorld(ClientScriptManager manager)
    {
        manager.RegisterClientScriptResource(typeof(JSLibrary.JSAccess), ScriptPath_HelloWorld);
    }//JSLibrary being the DLL namespace and JSAccess being the class

Then, in the main project, using Web Forms, you can call that method and pass it the ClientScript property of the current Page, where the scripts get registered, I assume. Like so:

protected void Page_Load(object sender, EventArgs e)
    {
        JSLibrary.JSAccess.includeHelloWorld(Page.ClientScript);
    }

I've tried it and it works on Web Forms. I need the equivalent of the Page.ClientScript in MVC, that I can send to the method in the DLL that takes in a ClientScriptManager.

Thanks

Answer:1

I want to change the div order through JavaScript. i didn't know how to do that This is the two div which implement in html, but i want div id="navigation" show in html after div class="row ...

I want to change the div order through JavaScript. i didn't know how to do that This is the two div which implement in html, but i want div id="navigation" show in html after div class="row ...

  1. change array order javascript
  2. change div order javascript
  3. change object order javascript
  4. change element order javascript
  5. change list order javascript
  6. change tab order javascript
  7. change dom order javascript
  8. change li order javascript
  9. change event order javascript
  10. change column order javascript
  11. change image order javascript
  12. change node order javascript
  13. change z order javascript
  14. change sorting order javascript
  15. change order of keys javascript
  16. change table column order javascript
  17. change order of execution javascript
  18. change json key order javascript
  19. javascript change order of elements in array
  20. change order of html elements javascript

I am coding a php/html page, with some javascript functions. I want to perform an INSERT on my MySQL Database if the result of one of my javascript functions is equal to 1. 01) How can I access the ...

I am coding a php/html page, with some javascript functions. I want to perform an INSERT on my MySQL Database if the result of one of my javascript functions is equal to 1. 01) How can I access the ...

I am trying to make a form where a customer can choose parson and automatically show the cost depend on parson number. So for that, I used jQuery form change function and calculate the cost inside of ...

I am trying to make a form where a customer can choose parson and automatically show the cost depend on parson number. So for that, I used jQuery form change function and calculate the cost inside of ...

I am trying to get some suggestions when I write something in HTML form. Hence,I call a JS function when onkeypress and onkeyup events are triggered on that form. In JS function I am using HTTP ...

I am trying to get some suggestions when I write something in HTML form. Hence,I call a JS function when onkeypress and onkeyup events are triggered on that form. In JS function I am using HTTP ...

  1. running javascript from command line
  2. running javascript from python
  3. running javascript from java
  4. running javascript from terminal
  5. running javascript from html
  6. running javascript from visual studio code
  7. running javascript from c#
  8. running javascript from php
  9. running javascript from command line windows
  10. running javascript from address bar
  11. running javascript from console
  12. running javascript from url
  13. running javascript from command line linux
  14. running javascript from browser
  15. running javascript from bash
  16. running javascript from powershell
  17. running javascript from chrome
  18. running javascript from command prompt
  19. running javascript from code behind c#
  20. running javascript from notepad