Using AJAX in WebSite Razor 3 - vb.net

I am programming a website in VS2013 in VBHTML (Razor 3).
This site does not use MVC.
I'm looking for documentation to use AJAX, but I only find information using MVC.
Does anyone know if it is possible to use AJAX without MVC????

Yes, it is possible to use AJAX in a non-MVC web application.
The below link should help get you started.
https://www.codeproject.com/Articles/691298/Creating-AJAX-enabled-web-forms
"Beginning ASP.NET 4.5.1 in C# and VB" by Imar Spannjaars walks you thru creating a website (not using Web Matrix) and chapter 13 is all about ASP.NET AJAX. This book uses websites instead of web applications and does not cover any MVC.
Also the book "Professional ASP.NET 4.5 in C# and VB" is also a good resource.
This book focuses on developing applications using webforms.
https://www.amazon.com/Professional-ASP-NET-4-5-C-VB/dp/1118311825/ref=sr_1_2?ie=UTF8&qid=1498491649&sr=8-2&keywords=ASP.NET+4.5
Hopefully this will help you out.
Best regards,
Joe

Related

What is the equivalent of WebForms in ASP.NET Core?

I am doing my final year project in Computer Science and the project is a system for managing a college, like openSIS, but using ASP.NET Core to build it.
I need help on how to Add, Update, and Remove data using regular HTML forms, such as via <form/> and <input type="submit"/>. I knew how to do this in WebForms, but not in ASP.NET Core.
What you're asking to do is possible "out of the box" with ASP.NET Core and does not require a third-party solution.
Solution #1: ASP.NET Core Razor Pages
Microsoft - Introduction to Razor Pages
This is probably the most direct approach with the least to learn, and it is the modern equivalent to "Classic ASP.NET Web Forms." You are probably asking about this:
The basic idea is you create an "ASP.NET Core Web Application" project in Visual Studio and select the "Web Application" project template (confirming that ".NET Core" is selected in the template selection dialog before you click OK.)
You can then add "Razor Pages" containing HTML, CSS, and JavaScript, and use a simple post-back method via a regular HTML Form with a Submit Button. The link above has a topic on doing just that.
Solution #2: ASP.NET Core MVC
Microsoft - Overview of ASP.NET Core MVC
This is the second-most direct approach but does require you to grasp MVC concepts: Models, Views and Controllers. Implementing Razor Pages would only require you to grasp HTML and Razor Page code-behind, however, MVC as a pattern will provide your resulting project with a more maintainable and testable approach to the project.
The basic idea is to scaffold an "ASP.NET Core Web Application" project in Visual Studio, then select the "Web Application (Model-View-Controller)" project template.
Instead of adding Pages you add Views, to do anything useful these Views will have corresponding Controllers. There will also be Models defined, as you would see in a Razor Pages solution. In the case of MVC the Models are posted to your Controllers via Actions.
The link above covers the subject in detail, and there are numerous Stack Overflow posts on general MVC concepts.
Solution #3: RESTful Web APIs and Client-Side JavaScript
Microsoft - Building Web APIs
This is probably the least direct and most-technical approach. You will want to be familiar with "JavaScript" and "XHRs", "JSON" (or XML, but JSON has become de facto), and you will want to be versed in what it means to be a "RESTful Web Service" ie. that HTTP supports basic verbs to POST, GET, and DELETE a resource.
The basic idea is you create an "ASP.NET Core Web Application" project in Visual Studio using the MVC scaffold. You then implement Controllers to behave as RESTful web services. You can add Razor Pages and/or MVC Views to deliver the HTML and JavaScript.
With this approach you can create "Single-Page Applications" that never need to reload, where the HTML and JavaScript for the entire application can be delivered up-front and then RESTful web services used to modify the UI at the client. This can get advanced, and most developers will want to look into using a client-side templating engine. The leanest and simplest to use is probably going to be KnockoutJS, but others are more popular (and more complex.) Knockout has the value of solving a very specific problem: data-binding an HTML UI to JavaScript objects.
Regardless of the approach you take, start here: Microsoft - Get Started with ASP.NET Core
If you like the Web Forms way of development, or if you have a large ASP.NET Web Forms application and you need to implement new pages in it, you can try DotVVM.
It is not "Web Forms on .NET Core", but:
many concepts in DotVVM are similar to ASP.NET Web Forms (postbacks, server controls, master pages, even the names of the controls and page lifecycle events)
it is easy to learn for ASP.NET Web Forms developers
no cryptic viewstate hidden field
the controls don't produce ugly HTML
the MVVM pattern is used
no need to know or write JavaScript - C#, HTML and CSS is enough to start coding
DotVVM supports both .NET Core and full .NET Framework
can be added to existing ASP.NET Web Forms or MVC applications on .NET Framework
DotVVM is open source
Visual Studio extension with IntelliSense and project templates
Disclaimer: I am one of the authors of DotVVM. This post is not meant to advertise the project, I just believe it responds to the question because the main motivation to build DotVVM was the fact that Web Forms are not ported to ASP.NET Core, and many people is looking for the similar way of building web applications. DotVVM is not a port of Web Forms to .NET Core. Our intent is to build a framework which is conceptually similar, but which avoids the things Web Forms were criticized for (viewstate, testability and ugly HTML output).
DotVVM GitHub
Documentation
Gitter Chat
If you are referring to WebForms from ASP.NET (before MVC webstack came), there is no WebForms for ASP.NET Core and unlikely to ever be ported.
There is however a similar project (usually referred as Razor Pages or View Pages, see RazorPages GitHub repository) which allows to create Razor views which are not backed by a controller.
But as far as I know it's not release ready (there is no nuget package for it on nuget.org) and you'd have to use some previous from nightly builds or stable myget repositories.

Can I use the ASP.NET AJAX Control Toolkit in my MVC4 Application?

I've spent a fair amount of time researching this, as I would rather not find out through trial and error.
Can I use the ASP.NET AJAX Control Toolkit in my MVC4 Application? Is there Microsft documentation that gives definitive information?
Yes, I know that MVC4 does not have VIEWSTATE. I am using the Razor view engine.
The documentation for the toolkit states specifically that it is for web forms, not mvc.
http://ajaxcontroltoolkit.codeplex.com/
If there is a specific piece of functionality you required, then you might want to see if there is a plugin available for jquery to replicate it.
http://api.jquery.com

Oauth In Asp.net Webapi?

I am learning how to use the asp.net webapi. I want to make an admin area where I can do admin stuff but also add,edit,delete stuff into my database.
I believe I need to make some regular asp.net mvc views and controllers for this. I of course want to secure these pages and only let authorized users in.
I would like to use Oauth. I know that mvc 4 now has build in support now for it but I am not sure which nuget package to download into my webapi project.
I am also unclear if you can register any oauth provider. I am looking at the asp.net mvc 4 internet soultion and I see like RegisterGoogle, RegisterFacebook yet I don't see an option for foursquare and I am not sure if I can add it myself or what.
There was an article that detailed a lot of this in May's issue of MSDN magazine titled Social Authenitciation in ASP.NET MVC 4. I think this has what you are looking for, but there is also another similar stack overrflow question answered in How to implement social login in asp.net mvc 4?

When to use the MVC4 Web-API vs a traditional HTTP web-service?

I noticed when the MVC4 beta was announced, it includes a new "Web-API".
(MVC 4 announcement)
In what circumstances should I use this Web-API instead of a normal HTTP/WCF Web-service?
What problem is it trying to solve?
The Web API allows you to very easily expose an API of some existing web site (or build a new one) using standard RESTful techniques. Achieving the same goal with WCF would be a little more challenging but could be done. Scott Gu wrote a nice overview of the Web API.

What framework should I choose to build a WCF Restful API

I am wanting to build a Restful API using WCF however I am struggling to make a decision on how to accomplish this.
The WCF Rest Starter Kit was developed for .Net 3.5 and has not progressed past Preview 2. Although it can be used within the current .NET Framework and within Visual Studio 2010 it seems from my research to be dead in the water and superseded by the new WCF Web API which is currently in Preview 5.
On the other hand the WCF Web API is only at preview stage and should not really be used in a production application as many things could possibly change before its release. There is also no indication if its nearing completion and if it’s going to be in the next .NET Framework release and when that is intended to be.
I find myself between rock and a hard place and look to the wider community to provide me with some guidance on this if at all possible.
You should regard this tweet from Glenn Block.
Using ASP.NET MVC for building a Restful API should be straight forward and easy way to do it.
However I've used WCF Web Api with WCF Rest Contrib in production without any problems.
See
Creating REST API with ASP.NET MVC that can speak both JSON and Plain Xml
RESTful Services With ASP.NET MVC
ASP.NET MVC – Create easy REST API with JSON and XML
Maybe OpenRasta is what you are looking for?
See also
RESTful framework alternatives to WCF
I depends on your application. If its a Website (also has views) that offers the REST API using ASP.NET MVC would be less technology, less effort, less know-how etc.
If its JUST an REST API choose what you like more from development style: ASP.NET MVC or WCF Web API