【问题标题】:MVC3 WebGrid - @Url.Action using image buttonMVC3 WebGrid - @Url.Action 使用图像按钮
【发布时间】:2012-05-22 18:56:34
【问题描述】:

我遇到了一个实际上我还没有解决的问题。由于某些原因,我请求将 Html.ActionLink 中使用的文本替换为更直观的设计,使用图像作为 WebGrid 内的按钮,用于修改、复制、发布和删除等常规操作。 阅读我尝试了很多方法,但没有一个让我进入最后阶段:

@{
    var grid = new WebGrid(Model, new List<string>(), canPage: true, rowsPerPage: 5);
    grid.Pager(WebGridPagerModes.NextPrevious);
        @grid.GetHtml(tableStyle: "webGrid",
        htmlAttributes: new { id = "DataTable" },
        headerStyle: "header",
        alternatingRowStyle: "alt",
        columns:
        grid.Columns(
        grid.Column("Description", header: "Description"),
        grid.Column("DateCreation", header: "Creation Date"),
        grid.Column("CompanyOwner", header: "Company"),
        grid.Column("Owner", header: "User"),
        grid.Column("Status", header: "Status"),
        grid.Column("Action", header: "Action", 
                          format: (item) => @Url.Action("publish", 
                                                        "PublishItem",  
                                                        new { id = item.ID })))
        );
    } 

为此,我从一个使用 linq 到实体创建的模型开始,我在其中添加了 Action 列,我想用它来放置我的按钮。如何像在普通表格中一样将图像放置为按钮:

<a href="@Url.Action("PublishPill", new { id = item.ID })">
<img src="../../Images/world_32px.png", alt="Edit" title="Publish" border="0" /></a>  

【问题讨论】:

标签: asp.net-mvc-3


【解决方案1】:

你可以使用

grid.Column(header: "Contraseña", format: @&lt;text&gt;&lt;a href="@Url.Action("ChangePassword", "Home", new { id = item.Identification })" &gt;&lt;img src="../../Content/images/password.png" alt="" style="border:none;" /&gt;&lt;/a&gt;&lt;/text&gt;, style: "colOperation")

【讨论】:

    猜你喜欢
    • 2013-01-08
    • 1970-01-01
    • 2011-06-20
    • 2013-07-11
    • 2013-09-18
    • 2012-05-05
    • 2012-12-01
    • 2013-10-09
    • 2012-02-18
    相关资源
    最近更新 更多