开发者

MVC: using BeginForm inside a custom HtmlHelper

开发者 https://www.devze.com 2023-01-28 09:22 出处:网络
I have the followin开发者_开发百科g code in a MVC view: <% using (Html.BeginForm()) { %> <input type=\"text\" name=\"id\"/>

I have the followin开发者_开发百科g code in a MVC view:

<% using (Html.BeginForm()) { %>
  <input type="text" name="id"/>
  ...
  ...
<% } %>

I want to refactor it to be reused. So I want to move this code into a custom HtmlHelper.

How do I use the Html.BeginForm in a helper?


Why not refactor it to a shared, partial view instead? Much easier than creating the helper method in code, in my opinion.

0

精彩评论

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