0

By design I have

<a href="#"><span><strong>ABOUT US</strong></span></a>

There is CSS which does some special things with span tag.

But I need to convert it into

@Html.ActionLink("ABOUT US", "About", "Home") 

So I have in some way to put span strong into @Html.ActionLink

Thank you for any clue!

NoWar
  • 36,338
  • 80
  • 323
  • 498

4 Answers4

9

Instead of using the Html.ActionLink helper, I would do it the following way:

<a href="@Url.Action("About", "Home")"><span><strong>ABOUT US</strong></span></a>
wycleffsean
  • 1,377
  • 1
  • 11
  • 16
1

You should try create your own custom html helper, here is some clue for you: Is it possible to use an ActionLink containing an element?

Hope this help :)

Community
  • 1
  • 1
shennyL
  • 2,764
  • 11
  • 41
  • 65
0

Use Url.Action to generate only url, not (a) link tag. See the follow link.

http://www.netrostar.com/MVCOutgoingUrls

wnascimento
  • 1,949
  • 1
  • 19
  • 16
0

Alternatively, change your css so that any <a> tags with a class "strong" have the style you want applied to them.

if your css is like this:

strong {
   /* whatever */
}

change it to

strong, a.strong {
   /* whatever */
}

Then you can style up your links just by adding class="strong" like this

<a href="#" class="strong">ABOUT US<a>

to get the same style applied to the link.

Then you can acheive the same HTML by going

@Html.ActionLink("ABOUT US", "About", "Home", null, new { @class = "strong"} ) ;

which will render a link with the class "strong"

StanK
  • 4,750
  • 2
  • 22
  • 46
  • Well... I guessed about this approach but in this case I have to change too much CSS :) Anyway - Thank you! – NoWar Nov 30 '11 at 01:51