Asp.net MVC Calling ActionLink in Codebehind

Posted by SSA on Stack Overflow See other posts from Stack Overflow or by SSA
Published on 2010-05-03T14:22:04Z Indexed on 2010/05/03 14:28 UTC
Read the original article Hit count: 600

Filed under:
|
|
|
|

I am new to asp.net and MVC, so please go easy on me. :)

I have successfully made a small MVC application. There is a database that contains a table named "Entry" and I have made Controllers for this. Also I have a view for Details and list. This works fin.

My problem is in my index page. (not the view Index, but the frontpage). There I dynamically build a TreeView as a menu, with some Categories. In this menu there is under the categories there is my Entries from the database. They show up fin.

I insert the entries as a TreeNode what holds the entry id and so forth. What I want is: that the entries in my treeview work as a link to the Detail view of the Entry. So if I click on a entry in the TreeView it will show the Detail page of this Entry.

But I can't make it work.

How to I use the <%= Html.ActionLink() %> in codebehind? Or is it this the wrong way? If calling the view or controller in codebehind is the wrong way to do it. Then how?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about mvc

Related posts about actionlink