views:

186

answers:

1

In the Details view of the HomeController, I'd like to create a link to the Email view on the MiscController. In addition, I need to add an item to the QueryString.

I'd like to create a link that goes something like:

<a href="http://www.blah.com/misc/SendMail?id=6"&gt;
    <font size="1">Report problems</font>
</a>

I've tried the following:

<% Html.ActionLink("<font size=\"1\">Report</font>", "SendMail", "Misc", Model.ImageID, new object()); %>

It returned no link. What am I missing?

+3  A: 

First of all, you missed the = after the <%. That's why it didn't output anything.

Also, the way you passed routeValues parameter was wrong.

It should be :

<%=Html.ActionLink("<font size=\"1\">Report</font>", "SendMail", "Misc", 
    new { id = Model.ImageID }, null /*htmlAttributes*/) %>

Please keep in mind though the text argument will be encoded in the output, so there's no point in sending HTML with that argument.
It's best to use CSS to style your HTML.

For example :

a.myLink {font-size: 0.5em;color:yellow;}

And to set the class attribute for the anchor element :

<%=Html.ActionLink("Report", "SendMail", "Misc", 
    new { id = Model.ImageID }, new { @class = "myLink" }) %>
çağdaş