Using MVC .Net Core Tag Helpers in MVC 5 - asp.net-mvc-5

Tag Helpers are a nice substitute for HTML Helpers in ASP.NET. Code is much easier to read when they're employed. To my knowledge, they're available in ASP.NET Core MVC.
Is it possible to use tag helpers in ASP.NET 4.x MVC 5? If so, then how do I go about doing it?
If not, is there a way to write code to create your own tag helpers for ASP.NET 4.x MVC 5?

This is a duplicated of this question. See the answer below.
No, tag helpers are only supported in ASP.NET Core, not in the older ASP.NET (based on the classic .NET Framework, rather than the newer .NET Core). But instead you can use HTML Helpers which do a lot of the same things.

Related

is jsf and .net webforms alike?thye are stateful,render their own html tags [duplicate]

This question already has answers here:
What is the need of JSF, when UI can be achieved with JavaScript libraries such as jQuery and AngularJS
(8 answers)
Closed 2 years ago.
Is JSF (javaServer faces) same technology as .net WebForm? why is it still in use? .Net is not supporting WebForm anymore
ASP.NET and JSF are similar.
JSF is still in use because it's part of Java Enterprise Edition. For example PrimeFaces is one of the largest Component collection and has lot of active users.
Microsoft moved to MVC and later to .NET core.
On the Java side you have Spring MVC as the equivalent.
Why is JSF still used: Because a component based model may have some advantages for enterprise business applications.
As always it depends and you have to choose the technology fits the requirements.
Btw. most frontends today are created using a SPA (Single Page Application) framework like Angular, React or Vue.

Progressive web app with asp.net core 2.0 Razor Pages

I want to create a progressive web app with ASP.NET CORE 2.0 using Razor Pages preferably because I like the code behind architecture of Razor Pages.
Please recommend me a tutorial or docs or any course where I can begin to learn this. I already know ASP.NET CORE so I don't need to learn that, but actually I want to learn and create PWA but at server side I want to use ASP.NET CORE 2.0 and Razor Pages (if possible). And then I will be hosting them in Azure.
The courses I've searched so far on the web, all of them are with node.js or any other server side technology. Which is a problem because I don't want to use JS, except on the front end, where I don't have a choice.
According to your description, I assume that you could refer to the following tutorials for getting started with PWA using .NET Core:
Yeoman PWA Angular 4 & .NET Core
PWA-Asp.NetCore
Building Progressive Web Applications (PWA) with Visual Studio
This is a very common misconception...that the client-side is tightly coupled to the server-side. They are not.
Your ASP.NET application renders pages/html on demand, at run-time, on the server. The site will work with or without the client-side code, that is why it is progressive....
Your PWA/Service Worker code is only concerned with stuff in the browser. You need to think about it as a stateless concern on the client. The service worker can add a proxy layer to the client-side where you can cache and really perform the task ASP.NET or Node Or PHP, etc perform, just in the browser, before the network must be used.
My advice, to learn the concepts, is to create a static version of your site or a test site. Get comfortable with how to make a PWA and a simple caching service worker, then apply it to your ASP.NET site.
There is nothing in ASP.NET itself your service worker needs to know about, well short of your routes. And your routes are independent of ASP.NET.

Is it possible to combine DevExpress MVC Extensions with DexExtreme components in standard MVC application?

We should make a decision in our company what architecture to use in new web project. We've already successfully used DevExpress' WPF components and thinking of buying their web products, but don't have enough experience with them. So, the next question is for people who have some experience with DevExpress' web components.
Could we start the solution as standard MVC project built in VS 2013 and then add DevExpress' MVC extensions such as data grid etc. and DevExtreme components (jQuery or AngularJS) as well? If we can do that, could you explain, please, what could be possible difficulties?
I think it isn't a good idea to mix up server-side DevExpress Mvc Extensions and client-side DevExtreme Widgets. If you are comfortable with asp.net mvc and want to use client-side javascript technologies, look at DevExtreme Mvc Wrappers.
It supports a convenient razor syntax to configure widgets. And you can use javascript to handle events, implement client-side templates etc.
To see how it works in action, refer DevExtreme demos.

VS 2012 All Toolbox items are greyed out [duplicate]

In ASP.NET MVC, do I use the "regular" controls from the toolbox and assign data to them like I did with webforms? Can I use the gridview, for example?
Thank you.
EDIT: The answer appears to be no. So what do you use? Are there any drag and drop controls in Visual Studio like the webform controls?
For the most part, use of MVC is explicitly not a drag/drop affair. There isn't a level of auto-wiring data-bound controls either. The purpose within MVC's structure is to give more direct control over the markup. There are some helper methods that can be used with rendering Form controls. MVC is a very different development model server-side. NOTE, you can combine ASP.Net with MVC into a hybrid project.
I would suggest that you need to be very comfortable with HMTL markup, and how HTTP + HTML communication works in order to be successful with an MVC project. The use of javascript is also very explicit. MVC is very nice with regards to a separation of concerns from back end, and front end in web based applications. This makes it easier to design and test the back-end logic, in comparison to the front-end rendering. It is a framework for web developers (web based applications are the first concern), not a developer framework for a web front end (ASP.Net controls based).
ASP.Net MVC is focused around generating your own HTML using your View Templates. You can't use Webform controls in your Views and have the application handle them the same way as with Webforms. They might render properly, but there is no postback functionality or concept of maintaining their state.
That being said, you can integrate ASP.Net Webforms with your MVC style pages as well. You can always check out the classic Hanselman walkthrough of having a "hybrid" asp.net application: http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx
I believe you can use any control that does not rely on postback functionality.
The answer is Yes and No. Preferrably No.
This is what the community fears, an aggressive blending of asp.net and MVC into an unrecognizable and unecessarily complicated kludge.
For anyone looking at MVC, I'd suggest:
Appreciate clean simple HTML. Empty
out your toolbox :-)
Surf and learn how to code controls
to be generated the way you need them
to. Strongly typed, powerful html
generators will come but I'd prefer
them to be clean and not wrapped in a
control, I want to see the code.
try not to mix asp.net and mvc (
tempting ) but unless you're forced
to, consider it a no-no
So to answer your question, MVC is still new, MVC Contrib, MVC Futures and Html helpers are avaiable in the framework and all over the web. Keep surfing and keep your own library of tweaks then post them so others can find and improve on them and vice versa. MVC can be the change the .net community has been waiting for, let's not go back to drag and drop so quickly.
Good luck!
No, any control that uses the __doPostBack JavaScript function to trigger postbacks will not work. Also there is no concept of ViewState in ASP.NET MVC so any control that relies on ViewState or ControlState will not work either.
The idea behind ASP.NET MVC is to take a different approach than the heavier WebForms model (and most of its controls).
Some controls from the WebForms toolbox will work just fine (although I believe the GridView is not one of them...) in ASP.NET MVC. The keys are that you can't use controls that rely on either
Postbacks (the __doPostback() javascript function), or
Viewstate
However, I'm not sure that you really want to use those controls. One of the main ideas with ASP.NET MVC is to regain control over your html markup - something you don't really have with a GridView. If you want to have a reusable grid layout to present data, I recommend using a PartialView or an Extension Method to the HtmlHelper class, depending on the complexity of your data.
You cannot use WebForms Controls in ASP.NET MVC directly.
But you can wrap any control inside an HTML helper.
Example a GridView:
public static class MvcGrid
{
public static string MyGrid(this HtmlHelper helper)
{
var grid = new GridView();
var source = new[]
{
"Foo",
"Bar",
};
grid.DataSource = source;
grid.DataBind();
var stringWriter = new StringWriter();
var writer = new HtmlTextWriter(stringWriter);
grid.RenderControl(writer);
return stringWriter.ToString();
}
}
But this will not function as a WebForm GridView.
It is just for rendering the HTML.

Can I use Moq with subsonic3?

I'd like to use a mocking framework as well as an IOC framework with my latest project, based on subsonic 3 (ActiveRecord) and ASP.NET MVC.
I'd like to use Moq for mocking and Castle-Windsor for IOC.
Anyone got any advice or recommendations based on these choices? Any bumps in the road I should be aware of?
Chris
I would definitely look into the Castle Windsor controller factory in MVC Contrib if you're using Castle for IOC with a ASP.NET MVC app.
Since Moq is completely separated from the app itself in the testing part of the code, I can see no reason that there would be any bumps in the road. I've been using Moq with a couple ASP.NET MVC apps with Castle Windsor IoC and on a app where I used Subsonic (though not in an ASP.NET MVC app) and have no complaints.

Resources