0

I got a problem that actually I do not yet solved. For some reasons I had a request to replace the text used in Html.ActionLink with a more visual design using images as button inside a WebGrid for the usuale operations like modify, duplicate, publish and delete. Reading I have tried many ways but none led me to the final stage:

@{
    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 })))
        );
    } 

To do that I start with a model created with a linq to entities where I added the column Action, the one that I want to use to place my buttons. How do I place the images to work as buttons as I done in a normal table:

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

1 Answer 1

2

You can use

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

Sign up to request clarification or add additional context in comments.

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.