English 中文(简体)
Html.ActionLink 图表
原标题:Html.ActionLink Image button

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" })%>

但这不行!

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

我有我的风格。

.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;
}
最佳回答

作为同一目标的一部分,你正在通过你的属性和航向。 应:

    public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes);
问题回答

大多数人都建立了Ajax。 图像行动链接帮助器,但在有些情况下,使用Html更为合适。 象这里的图像行动链接帮助者:

http://lottemae.wordpress.com/07/04/html-imageactionlink-cus-tom-helper-for-mvc/





相关问题
Using jquery to get a partial view and updating the UI

I need to render a partial view (returned from the controller) to show some customer summary details. This will need to happen when the user clicks on a button. In the the mean time the user can ...

MVC 2 / MVC 3 / MVC 4

MVC 2 我们可以轻松地创造领域。 现在,我的问题涉及nes地区(地区内)。

Asp.Net MVC 2 - Changing the PropertyValueRequired string

Using a resx file in the App_GlobalResources directory, I ve been able to change the default message for the PropertyValueInvalid string of the model validators. But it doesn t work to translate the ...

ASP.NET MVC 3 - What features do you want to see? [closed]

I know a bunch of people that are really enjoying the improvements that ASP.NET MVC 2 made over the first release. I have just started to migrate our MVC 1 project over and so far areas has totally ...

热门标签