MVC Razor localization how to - razorengine

What is the best approach to localize text in Views? I am using MVC 5 and Razor.
Would it be Resource files or IviewLocalization or other?
Samples and ideas are appreciated

Related

In ASP.NET Core 6 Razor Pages how do I CRUD the Users and Roles?

I have followed this monumental tutorial Create an ASP.NET Core web app with user data protected by authorization which gave me a good oversight for Authorization.
However I still can't find a way to simply CRUD Roles and Users. Anywhere! The best I have seen are tutorials in MVC on making a list of users and roles. But that conflicts with my existing program.
There are a number of old tutorials, some still on the MS website, for MVC, webforms, etc, but nothing for Core 6 Razor pages.
Is there a CRUD of Core 6 ASPNetRoles and ASPNetUsers? If not why not? Is it a security issue? Does everyone roll their own? Is it so easy that I just don't get it?
Edit: As an update, I found this excellent resource https://github.com/mikebrind/Razor-Pages-In-Action/tree/main/Chapter10 if anyone else is looking for guidence.
They still exist, except much less is included in the template.
If you start with the .NET 6 Templates ex;
MVC - dotnet new web --auth individual
Razor Pages - dotnet new razor --auth individual
Blazor - dotnet new blazor --auth individual
It will kick you out a template with: Bootstrap CSS, Entity Framework and a database with the Identity Library and a Razor Class Library for the Register and sign in, etc.
From here, you are provided abstractions like IdentityUser, IdentityRole and base classes like RoleManager. There aren't any implementations or frontend code provided out of the box.
These abstractions give you the flexibility to opt-in, and tailor to suit your organizational requirements. CRUD is rather simple and will take very little effort to implement.
Reference Source for CRUD RoleManager in MVC -> https://github.com/procodeguide/Sample.Identity.Roles/blob/main/ProCodeGuide.Sample.Blog/Controllers/RoleController.cs

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.

Using MVC .Net Core Tag Helpers in 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.

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.

Saving User Input in a JBoss Seam Web Project web page

I have a question for any JBoss Seam developers out there:
I am creating a web project using JBoss Seam by generating entities and reverse-engineering code from existing database tables. This is my first time developing a web app in JBoss/Java/JSF, being an old school .NET web developer from years ago.
How do I save user input in text controls, so that it stays on the web page after a page refresh? I used to use Viewstate or Sessionstate in .NET, not sure what the equivalent of this would be in Java/JSF. Someone mentioned using java beans, but not sure how to do that, and Googling produces little help.
Any comments much appreciated, thanks.
Rather than going through the steps required here, it might be easier for you to go through the Seam tutorial, which will give you the basics. You can then clarify things here afterwards:
http://docs.jboss.org/seam/latest/reference/en-US/html/tutorial.html#registration-example

Resources