Click here to Skip to main content
14,431,103 members
Rate this:
Please Sign up or sign in to vote.
So I'm new to web programming, mostly used to C#, but now I'm stuck tring to do an insert to a DB over a week.....
It is pretty simple, I have a form in Razor, when the user finishes he clicks a button that should insert it to the DB, but I'm not being able to make this insert.
I was able to use JavaScript to create the insert line, but I can't make it go to the DB.
Can anyone please give me an example of how I can make this Javascript line go to the DB ?

Thank you very much!

What I have tried:

Copied all examples I could find... very few, most stuff is in the old MVC format and not Razor...
Posted
Updated 13-Jul-19 15:54pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Razor is a View Engine, and is the default for Asp.Net MVC sites. The early Asp.Net sites used the web-forms engine.

Or are you mis-associating Razor as being for WebApi?
   
Comments
Rafael321 15-Jul-19 9:56am
   
Thanks for the reply, but actually I mean the new Razor Pages instead of the classic model, view, controller, in visual Studio, but making this shorter, I have values in javascript that I need to send to a database, I'd use ADO ir ODBC in C# but I don't know how to do it in web...
Thanks
MadMyche 15-Jul-19 10:26am
   
Read this: https://stackify.com/asp-net-razor-pages-vs-mvc/
Michael Breeden 28-Oct-19 20:11pm
   
Hi Mad... Thanks but I found that article before. We're going back to 2010 I guess. It is very interesting but does not show how to use a Page in a Core MVC project. It's easy in MVC 5. The other thing is though that it says you should use MVC for AJAX. I am hoping I can use it with a Razor Page like an ASPX page (WebMethod). I do a very complicated AJAX and I like it in Pages. I hope I can figure out how to use Pages in Core MVC and use AJAX with them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100