开发者

form tag does not show

Using开发者_开发百科 asp.net mvccontrib grid. When using the custom column, the form tag isn't shown:

@(Html.Grid<SomeModelType>(Model.PagedList)
  .Columns(columns => 
  {
      columns.Custom(
          @<text>
               @using(Html.BeginForm("DeleteAction", "Controller", new { Id=@item.UserId}))
               {
                   <input type="submit" value="Delete" />
               }
           </text>
      );
  })
  .Sort(Model.GridSortOptions)
)

It outputs: <input type="submit" value="Delete" /> in the column.


Try like this:

@(Html
    .Grid<MyViewModel>(Model)
    .Columns(columns => 
    {
        columns.Custom(model => Html.Partial("_DeleteLink", model));
    })
    .Sort(Model.GridSortOptions)
)

and inside the _DeleteLink.cshtml partial:

@model SomeModelType
@using(Html.BeginForm("DeleteAction", "Controller", new { id = Model.UserId }))
{
    <input type="submit" value="Delete" />
}


Why would you use @<text> </text>?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜