如何添加HTML中的ASP.NET MVC 3的WebGrid列名(标题) [英] How to add Html inside ASP.NET MVC 3 WebGrid Column Name (Header)

查看:437
本文介绍了如何添加HTML中的ASP.NET MVC 3的WebGrid列名(标题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法添加HTML的WebGrid列名内(在头)?当我添加HTML列名称,然后带的WebGrid codeS里面。这是不可能增加的WebGrid列名里面的html?

I am unable to add html inside WebGrid column name(at header)? When I add html inside column name then webgrid encodes that. Is this is not possible to add html inside WebGrid column name?

推荐答案

有是改变HTML由MVC助手生成的一种方法,但它不是很舒服。
一般来说,你可以这样写命令:

There is a method to change html generated by an MVC Helper, but it's not very comfortable. In general you can write this command:

@( new HtmlString( Component.HelperMethod().ToHtmlString().Replace("[replacetag]", "My Content")) )

下面是使用网格组件的例子:

Here is an example using a grid component:

<div id="grid">
    @(new HtmlString(
        grid.GetHtml(
        tableStyle: "grid",
        headerStyle: "header",
        rowStyle: "row",
        footerStyle: "footer",
        alternatingRowStyle: "altRow",
        columns: grid.Columns(
                     grid.Column("Name", "[replacethis]"),
                     grid.Column("Surname", "Surname"),
                     grid.Column("Email", "Sender Email"),
                     grid.Column("Id", "", format: (item) => item.GetSelectLink("Select"), canSort: false))
).ToHtmlString().Replace("[replacethis]", "<b>Name</b>")
)
)    
</div>

这篇关于如何添加HTML中的ASP.NET MVC 3的WebGrid列名(标题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆