|
Heck, I don't write ASP.NET apps if I can help it.
|
|
|
|
|
Don't worry, I am sure by the end of the week MS will release some new "next big thing"...Forget about last weeks "next big thing".
Common sense is admitting there is cause and effect and that you can exert some control over what you understand.
|
|
|
|
|
It is true that Tag Helpers have a HTML-friendly syntax, but HTML Helpers have a Razor syntax which I feel is natural in ASP.NET Views, so it seems to me that it is intuitive and readable to most ASP.NET developers...
What was the point of this feature?
It is mentioned that: "The markup is much cleaner and easier to read, edit, and maintain than the HTML Helpers approach."
That conclusion seems rather subjective, the only ones that I feel could benefit from this is non ASP.NET developers that are familiar with any JS framework (like Angular, React, Vue, etc.).
Well at first that seems as if it could be beneficial, but then again what about the rest of the Razor syntax that will be present in the View?
Also does this encourage us to have two syntax in our Views?
Also I don't get how removing the C# with HTML is easier to edit and maintain?
You just replaced the C# code with magic strings, if anything you lost quite a few features because of that...
|
|
|
|
|
Message Closed
modified 1-Sep-17 1:47am.
|
|
|
|
|
Robert_Dyball wrote:
Tag Helpers can be like an old fashioned macro, one small bit of markup on the page and you can get a lot of time-saving HTML created.
You get this with HTML Helpers as well.
Robert_Dyball wrote:
If you are using PoMVC (plain old MVC) views you'll probably find after a while there's similar looking chunks of code all over the app, and depending on the size of the site, these repetitive code chunks might be moved into tag helpers. IMO makes for easier changes later.
Also you can create your own HTML Helpers and you could even use partials for this...
Robert_Dyball wrote:
If you like living dangerously, try out: SPA[^]
where I use Tag Helpers in ASP.Net Core MVC partial views to serve my SPA it's HTML views
To be honest I lost faith in Angular team a long time ago, but nevertheless again you could have just used the HTML Helpers to achieve the same.
For example, in one occasion I used them for adding Vuetifyjs components.
In short, I'm not sure if you just wanted to post a link to your article or if you really believe that there is something valuable that Tag Helpers provide over HTML Helpers...
|
|
|
|
|
ouch ... sorry wasted your time, I incorrectly assumed you weren't familiar with tag helpers.
The link I gave was in good faith to provide examples + further links, and some caveats and I hoped in a tone that did not sound like I new it all - I don't.
you are entitled to assume self promotion, I think this odd, as I get a negative benefit - having not got any pay for the articles in the first place (they cost me much of my own spare time to write), and take further time if anyone asks questions. In other words to me it's a cost.
So here's a link (not mine), that compares HTML helpers and Tag Helpers:
[^]
I'll delete my earlier reply to avoid further wasted time and any hint of self promotion.
|
|
|
|
|
Apologize if that sounded rough, that was not my attention. I don't care if you are promoting or not (FYI I'm a writer too), you really did not have to delete your previous message.
Nevertheless the point I was trying to make is that the text felt quite generic... there was no concrete example as to why one would consider tag helpers over existing solutions.
I literally read your message like this: "you can do this, you can do that, see my article I'm using them like that"...
Also thank you for that comparison link, this is actually exactly the problem that I'm talking about, so now we have two syntax.
HTML Helper:
@Html.Label("FirstName", "First Name:", new {@class="caption"}) Tag Helper:
<label class="caption" asp-for="FirstName">First Name:</label> Currently tag helpers do not fully replace the html helpers (there is no tag helper for each html helper), so does that mean that we'll have to use both syntax?
Also the conclusion that article makes is: "The markup is much cleaner and easier to read, edit, and maintain than the HTML Helpers approach."
My question is how, how is that easier to edit and maintain?
If anything I feel this has drawbacks, for example here are few things at the top of my head:
- You cannot use "Find All References" or any similar action to navigate or search for.
- You cannot use "Quick Actions and Refactorings..." for fast and accurate editing, for instance changing all "Label" to "MyCustomLabel".
- Etc.
|
|
|
|
|
Mario Z wrote: Also the conclusion that article makes is: "The markup is much cleaner and easier to read, edit, and maintain than the HTML Helpers approach."
My question is how, how is that easier to edit and maintain?
IMO HTML helpers were something of a mystery, no intellisense - you no idea as you're editing if you had to spell firstname as FirstName or if it mattered, or was remotely correct. I suppose someone could have added intellisense, but the Tag Helper alternative at least looks/feels more like HTML (for those who have no idea of C#, Razor etc).
Tag Helper classes for example, case in point. I'd rather edit class="xxx" with some training wheels (aka intellisense) than wonder what on earth to put in new {@class="xxx"} ... but what do I know, except I get older, I forget more stuff than I never knew, and anything that makes it easier works for me.
Anyway thanks for your reply, like most things - there's lots of choices, stick with whatever works for you.
I know some people who can't understand why I don't like tripe and onions, I'm happy without - but though puzzled, they are too (more in the world for them).
|
|
|
|
|