I have an asp mvc application. in a view i have this snippet:
@Html.Label(admin.Mail)
The result is false because of the special caracter @
. So how can i avoid this error and read exactly the label?
I have an asp mvc application. in a view i have this snippet:
@Html.Label(admin.Mail)
The result is false because of the special caracter @
. So how can i avoid this error and read exactly the label?
If you want to display the email address, Use DisplayFor
html helper method.
If Mail is a property of the Model passed, You can do it like this
@Html.DisplayFor(x=>x.Mail)
If Mail
is a property of of a sub collection of your model, you can display it like this
@foreach (var i in Model.Contacts)
{
<div> @Html.DisplayFor(s=>i.Mail)</div>
}
If your question is how do you escape @
in Razor, the way to do it is @@
.
Or you can try to write just the text-> something like <label>@admin.Mail</label>
EDIT
You can also give this a shot:
@Html.Display(admin.Mail)
Wrap your text with <text></text>
tags, for example <text>mail@gmail.com</text>