Asp.net MVC Calling ActionLink in Codebehind
- by SSA
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.