Passing parameter to controller action from a Html.ActionLink

You are using incorrect overload. You should use this overload public static MvcHtmlString ActionLink( this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, Object routeValues, Object htmlAttributes ) And the correct code would be <%= Html.ActionLink(“Create New Part”, “CreateParts”, “PartList”, new { parentPartId = 0 }, null)%> Note that extra parameter at the end. For … Read more

ASP.NET MVC Ajax.ActionLink with Image

From Stephen Walthe, from his Contact manger project public static class ImageActionLinkHelper { public static string ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string actionName, object routeValues, AjaxOptions ajaxOptions) { var builder = new TagBuilder(“img”); builder.MergeAttribute(“src”, imageUrl); builder.MergeAttribute(“alt”, altText); var link = helper.ActionLink(“[replaceme]”, actionName, routeValues, ajaxOptions); return link.Replace(“[replaceme]”, builder.ToString(TagRenderMode.SelfClosing)); } } You can now type … Read more