Comments (17)
The tag helper documentation lives on the ASP.NET doc site.
from entityframework.docs.
I think this refers to the Getting Started with ASP.NET 5 article we have. I'm personally not a fan of tag helpers, which is probably why they aren't used in the tutorial... but I agree being consistent with the template is a good idea.
from entityframework.docs.
Should consult with @DamianEdwards on the best practices here.
from entityframework.docs.
http://docs.asp.net/projects/mvc/en/latest/views/tag-helpers/authoring.html
http://docs.asp.net/projects/mvc/en/latest/views/tag-helpers/intro.html
Early feedback on my two TH articles is great. Run through my TH tutorials and I'm sure you'll love them.
from entityframework.docs.
I have no problem adjusting the article to use tag helpers, that is definitely the right thing to do from a consistency point of view. I'm about to update everything to Beta 8 so I will do that at the same time.
Regarding liking tag helpers... for me personally it makes it too hard to distinguish between code and html. The thing I love about razor is that it's really clear what is code and it's just the same C# I write everywhere else in my application. With tag helpers that is completely obscured away.
from entityframework.docs.
Read my intro doc - if you're using the default or light theme, TH/C# code is in a bold purple font. If you’re using the “Dark” theme the font is bold teal. I won't repeat the other advantages here, but I'm confident after using TH you'll grow to love them.
from entityframework.docs.
GitHub doesn't know about them so I lose all that context when I'm looking at diffs, PR's etc. That's not my main issue though, if I look at this piece of markup... I have no idea what it's doing. If it was just calling APIs though I could go look at them, read Intellisense, etc.
<environment names="Development">
<link rel="stylesheet" href="~/lib/bootstrap/css/bootstrap.css" />
<link rel="stylesheet" href="~/lib/bootstrap-touch-carousel/css/bootstrap-touch-carousel.css" />
<link rel="stylesheet" href="~/css/site.css" />
</environment>
BTW I'm not saying they don't provide value and that there aren't a bunch of folks who will like them... I'm just not one of them. I just want C# code and no magic/abstractions.
from entityframework.docs.
@Rick-Anderson quick question, how do use the asp-for
when I accessing something in a for
loop? It looks like the default scope is to try and access the supplied item from Model
but in this case I'm enumerating over the results of the model.
Here is the code, see where I'm trying to replace @Html.DisplayFor(modelItem => item.BlogId)
with a tag helper.
@foreach (var item in Model)
{
<tr>
<td>
<label asp-for="BlogId" />
@Html.DisplayFor(modelItem => item.BlogId)
</td>
<td>
@Html.DisplayFor(model => item.Url)
</td>
</tr>
}
from entityframework.docs.
@NTaylorMullen @rynowak can you answer @rowanmiller question?
from entityframework.docs.
@rowanmiller You can do: <label asp-for="@item.BlogId"></label>
from entityframework.docs.
@NTaylorMullen should that go in authoring TH or advanced?
from entityframework.docs.
You put an @
in front of the expression, then you can point it to whatever you like: asp-for="@item.BlogId"
from entityframework.docs.
@Rick-Anderson Not authoring, it's more of a usage behavior for ModelExpression
properties which are used by Mvc TagHelper
s.
from entityframework.docs.
We should not recommend foreach
with expressions such as @item.BlogId
or lambdas such as model => item.Url
in general. They work fine in this display-only scenario but a generated <input>
or <label>
will have incorrect id
or for
attributes (respectively) and won't be bound correctly on submission. Need to mess with ViewData.TemplateInfo.HtmlFieldPrefix
when using foreach
. That's less straightforward than:
@for (var i = 0; i < Model.Count; i++)
{
<tr>
<td>
<label asp-for="@Model[i].BlogId" />
@Html.DisplayFor(model => model[i].BlogId)
</td>
<td>
@Html.DisplayFor(model => model[i].Url)
</td>
</tr>
}
from entityframework.docs.
Yeah the @
prefix didn't work for me either, it just displayed blank data.
It's also super weird because anywhere else @item.BlogId
within markup would be resolved to its actual value by running the code and then that value used in the tag. Now I need to know that @
behaves differently depending on whether it's in a normal HTML tag or a Tag Helper.
I've swapped over to tag helpers everywhere else in #45. I'll leave this section as-is for the moment.
from entityframework.docs.
@rowanmiller @item.BlogId
is still resolved to the expression's "actual value", just a bit later.
As soon as you type @
anywhere, Razor puts you in a C# context. The difference w/ asp-for
is that you're already in a C# context, after someLambdaParameter => someLambdaParameter.
(note the trailing period). After the @
, you're in a different C# context -- instead after someLambdaParameter =>
.
from entityframework.docs.
This is done in 3eba324, aside from the for loop scenario being discussed here (where it sounds like tag helpers are not the right thing to use).
from entityframework.docs.
Related Issues (20)
- "Update" code sample is really Add HOT 2
- Problem with instslling Entity Framework SQL Server HOT 2
- StringToNumberConverter HOT 1
- Unable to create a 'DbContext' of type ''. The exception 'Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions`1[mywebsite.Data.ApplicationDbContext]' while attempting to activate 'mywebsite.Data.ApplicationDbContext'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728 HOT 6
- Add back setter for scaffolded collection navigations HOT 4
- Typo in link redirects to wrong site HOT 3
- s
- VS Community 2022 cannot install dotnet-ef when i try to publish. HOT 1
- Document ListValueComparer breaking change
- Document MsBuild integration
- Documentation improvement about data-seeding
- Concerning DbContext disposal HOT 1
- missing defaults information HOT 1
- I cant make use of the Entity.FrameworkCore HOT 1
- Missing doc about Primitive Collections HOT 1
- Doc does not address the most common use-case, when DbContext is injected
- Entity Framework Core 9 HOT 2
- AddRange & Internal Snapshot Method Missing Info
- Primitive Collection Must Implement IList
- Please provide some code samples how to use it in reality. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entityframework.docs.