开发者

form tag does not show

开发者 https://www.devze.com 2023-02-21 22:49 出处:网络
Using开发者_开发百科 asp.net mvccontrib grid. When using the custom column, the form tag isn\'t shown:

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

精彩评论

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