MVC 3: ActionLink VB.Net
- by xamlnotes
Theres not a ton of good samples out there on using MVC with VB, so I am going to post some things that I am doing on a project. Lets look at links. I am converting a asp classic app to mvc. One page has an anchor tag which I modified to look like so to point to a controller action: <A style=color:red; HREF='Detail/" & currentItem.IdNumber & "'>" & currentItem.IdNumber & "</A> This resolves out to what looks like the right URL and in fact the detail action is fired. The actions signature looks like so: Function Detail(ByVal IdNumber As String) As ActionResult But, IdNumber would always be blank, it was never set to the id passed in the url. Hmm. So, I tried the following by using the ActionLink method of the html helper: Html.ActionLink(currentLead.LeadNumber, "Detail", New With {.IdNumber = currentItem.IdNumber }) Viola! That worked fine and the Detail method parameter was set just like it should be. Very interesting.