How to store JavaScript files and call .NET to use Ajax

I am new to coding and working on a project in Visual Studio 2010 using VB. I want to implement Ajax in my solution, and I think that for this I should use .js files. My question is that I can get the appropriate JavaScripts to create the files, how to store them in my solution and what I actually call the class that I created. I assume the .js file will be split into .aspx and .aspx.vb files. Any help would be appreciated.

I searched on the Internet, but I can not find anything that shows how to create a .js file, and then run it on the corresponding page. To give you an idea of ​​my plans, I have a user database that is presented on a website through a gridview table. I want to use Ajax to allow me to drag rows in a table to move users. When you rearrange the database, you will need to update to show where each user is now in the table. I will use a field called "UserID" for this, which is an int.

Sorry for the incoherent communication. Just trying to be as concise as possible. Thanks guys

+4
source share
1 answer

Aspx mainly uses html semantics (with some cs or vb elements inside it), so you can include a script tag like in any html file. For example, you can have (for me, this is in C # and on my main page):

 <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="_Site.master.cs" Inherits="MyProject.SiteMaster" %> <!doctype html> <html lang="fr" class="no-js"> <head runat="server"> ... </head> <body> ... <asp:ContentPlaceHolder ID="MainContent" runat="server" /> ... <script src="~/Scripts/External/jquery-1.7.2.js" type="text/javascript"></script> <asp:ContentPlaceHolder ID="otherScripts" runat="server" /> </body> </html> 

and my global script is located in a folder (in the same project as the project file) called "Scripts". Moreover, I have a placeholder to add small scripts per page. enter image description here

0
source

Source: https://habr.com/ru/post/1447260/


All Articles