I’m using a model with DataType.EmailAddress. I would like to modify the address link in the run time, however it already has email link automatically that prevents my modification.
@{
var subject = "";
if (Model.Name.Length > 30)
{
subject = Model.Name.Substring(0, 30) + "...";
}
else
{
subject = Model.Name;
}
}
<a href="mailto:@Html.DisplayFor(model => model.email)?subject=Re: @subject">model => model.email</a>
But I got
<a href="mailto:<a href="mailto:emailaddress">emailaddress</a>?subject=Re: subject"><a href="mailto:emailaddress">emailaddress</a></a>
instead of
<a href="mailto:<a href="mailto:emailaddress">emailaddress</a>?subject=Re: subject">emailaddress</a>
Why the email address is converted into link form automatically? And how to stop it? I would like to keep the datatype to use validation though.
You’re trying to print the value of the property:
@model.Email.DisplayForis not what you want.Also, you need to URL-encode the
subjectparameter, including the space afterRe:.