views:

30

answers:

2

Hello,

I've this link on a page

<% = Html.ActionLink(item.Title, "Edit", "ArticleManagement", 
                      new { id = item.ArticleDataID })%>

and a simple method to receive the article Id

public ActionResult Edit(int id)
{
  //Do something
}

Unfortunately, I'm getting an error" parameter dictionary contains a null value for parameter id of int32 for Edit(Int32)..."

When I check the Url, I see something like "http://localhost:59786/ArticleManagement/Edit?Length=17"

What is "Length=17"? and what's doing there? Anyway, so far I'm working with a collection that has only 3 items on it.

Thanks for helping

A: 

I've had this happen as well, it seems to happen when the actionlink can't match to a route.

Length 17 corresponds to the length of articlemanagement.

Edit: It might have something to do with the overload of ActionLink.

Simon Hazelton
+2  A: 

You need to add null as the last parameter:

<%=Html.ActionLink("Title", "Edit", "ArticleManagement", 
        new { id = 1 }, new { @class = "link-class", attr = "attribute value" })%>

I think it uses you route values as html attributes without the null.

Castrohenge
@KieranMaine: It make sense now. It's working now. So if I want to use both route valuees and html attributes, how do I do it?
Richard77
Edited the answer.
Castrohenge
@Kieramaine: nice. and thanks very much
Richard77