Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
732 views
in Technique[技术] by (71.8m points)

asp.net mvc - Html.Label to display email address

I am using Html.Label to display some data in my MVC applilcation. When I am trying to display email address it does not render properly

Model.CopyToEmail = [email protected]
@Html.Label((string)(Model.CopyToEmail))

but the rendered output that i see is

com

Could anyone please suggest how to display using Html.Label

[email protected] 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Html.Label takes a field to display a <label> tag for.
It's reading your string as a nested property, and printing the name of the innermost property.

You just want to write ordinary text:

@Model.CopyToEmail

You can also call @Html.DisplayFor(m => m.CopyToEmail).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...