Asp.net-mvc – How to use a div element to redirect with MVC htmlhelper

actionlinkasp.net-mvchtml-helper

I have a bunch of div elements that look like this at the moment:

<div  onclick="window.open('Technology','mywindow');" class="grid" id="technology">                    
     <p class="category-title">Technology</p>        
</div>

I would like to get rid of the window.open and instead use MVC htmlhelper like actionlink to redirect users when they click on the div element. How can I do that?

Best Solution

The correct way to handle this is with a simple anchor tag.

Replace "myAction" and "myController" with the location you want to redirect the user to.

<a href="@Url.Action("myAction", "myController")">
    <div class="grid" id="technology">                    
         <p class="category-title">Technology</p>        
    </div>
</a>