user8549227
user8549227

Reputation:

String with email format turns into Hyperlink

Hi this probably is an easy question but i cant find information about how to solve it i have a table with a field named Email and the values are of type string but the problem is that mvc or the browser automatically changes that string email into Hyperlink as shown in the following picture

enter image description here

when i inspect the element it is an hyperlink:

<a href="mailto:[email protected]">[email protected]</a>

what can i do to only display the emails as string? i don't want that information to be in hyperlink format. thanks very much

Edited: here is my code of the view

<table class="table table-bordered table-striped">
    <tr>
        <th>Email</th>
        <th>Contraseña</th>
        <th>NickName</th>
        <th>TipoUsuario</th>
        <th>Acciones</th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>@Html.DisplayFor(modelItem => item.Email)</td>
            <td>@Html.DisplayFor(modelItem => item.Contraseña)</td>
            <td>@Html.DisplayFor(modelItem => item.NickName)</td>
            @if (item.TipoUsuario == 1)
            {
                <td>Administrador</td>
            }
            else
            {
                <td>Vendedor</td>
            }


            <td>
                @Html.ActionLink("Editar", "EditarUsuario", new { id = item.IdUser }) |
                @Html.ActionLink("Eliminar", "EliminarUsuario", new { id = item.IdUser })
            </td>
        </tr>
    }
</table>

and here is the code of my controller:

IList<Usuario> UsuarioList = new List<Usuario>();
                    var query = from usu in database.ReportingUsersT
                                where usu.Activo == 1
                                select usu;
                    var listdata = query.ToList();

                    foreach (var Usuariodata in listdata)
                    {
                        UsuarioList.Add(new Usuario()
                        {
                            IdUser = Usuariodata.IdUser,
                            Email = Usuariodata.Email,
                            Contraseña = Usuariodata.Contraseña,
                            NickName = Usuariodata.NickName,
                            TipoUsuario = Usuariodata.TipoUsuario

                        });
                    }

                    return View(UsuarioList);

Upvotes: 2

Views: 522

Answers (1)

Aaron Roberts
Aaron Roberts

Reputation: 1372

@Html.DisplayFor(...) is determining that the text is an email and is wrapping it in a link. You can simply use

<td>@item.Email</td>

to display it as text

Upvotes: 3

Related Questions