0

I am using MVC 3, ASPX pages. I am trying to make an image button for ActionLink: This one works well:

   <%: Html.ActionLink("New", "AccessCode", null, new { @class = "but_add" })%>

but this one did not work!!

  <%: Html.ActionLink("New", "Create", "CourseChapters", 
              new { courseId = ViewData["TestId"], @class = "but_add" }, "")%>

I have the class in my style sheet

.but_add
{
    background-image: url('../../Content/images/b_add.gif');
    background-repeat: no-repeat;
    width: 85px;
    height: 27px;
    padding-left: 27px;
    cursor: pointer;
    display: inline-block;
    padding-top: 5px;
}

2 Answers 2

2

You are passing your html attributes and routeValues as part of the same object. Should be:

    public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes);
Sign up to request clarification or add additional context in comments.

Comments

0

Most people create an Ajax.ImageActionLink helper, but in some cases it's more appropriate to use an Html.ImageActionLink helper like the one here:

http://lottemae.wordpress.com/2011/07/04/html-imageactionlink-custom-helper-for-mvc/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.