I've been working on an ASP.NET MVC project and needed to nest an <h2> element inside of an anchor tag because of a CSS-only menu I am using.

<a href="http://somethinghere.com/page/1"><h2>Link Text</h2></a>

If you use the traditional ActionLink method in ASP.NET MVC, you can't do that. At least, I haven't found a way how.

I did find a work-around, courtesy of Stack Overflow:

<a href="<%= Url.Action("show", "page", new { id = Parentpage.Id }) %>"><h2><%= Parentpage.PageName %></h2></a>

It's a hack, but it produces the correct output.


View Comments: Comments (0) |

Add comment


(Will show your Gravatar icon)

biuquote
  • Comment
  • Preview
Loading



Recent Comments

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.