I have something like in MVC (I am using MVC c# using razor):
@Html.ActionLink("Edit", "EditProject", new { id = item.ProjectID})
produces something like when I look at the source code:
<a href="/iDVI/Project/EditProject/535">Edit</a>
Note how 535 was the result of having item.ProjectID.
This is fine. What I like to do though is to put an id for this edit link. Something like:
<a href="/iDVI/Project/EditProject/535" id="Projectid">Edit</a>
How do I do this. I know using new{id=…} will create a id but and id is already used for what I intially needed to do.
I need to give an id to the link now?
You have to look at the signature of the method when you are using it.
When you wrote:
you used the following overload:
So this is why you were getting your item.ProjectID as a part of the url. It is a routeValue in this case.
The overload that you are looking for is probably this one:
Using this overload you specify that you want to use your variable item.ProjectID as a part of url as well as an attribute of the link:
If you actually want to spell out the name of the variable, you would write:
This gives you the desired output.