Looking for a Html.SubmitButton helper that would accept class attributes in MVC3

后端 未结 6 1313
野性不改
野性不改 2020-12-31 08:42

I would like to use a helper for Submit button in MVC3. Is such a thing available? If not, then does anyone know where I could get some code for this. I would like one that

6条回答
  •  我在风中等你
    2020-12-31 08:53

    There isn't a HTML helper for a button because the HTML helpers reflect over a model's propertys and help you by setting the correct attributes for binding purposes, they also look at the VilidationAttribute metadata for that property (if any) and add any jQuery validation attributes.

    Buttons are not part of the model and so do not have any helpers.

    You can crate your own HTML helper by following this article http://www.asp.net/mvc/overview/older-versions-1/views/creating-custom-html-helpers-cs or using the TagBuilder class: http://www.asp.net/mvc/overview/older-versions-1/views/using-the-tagbuilder-class-to-build-html-helpers-cs but I prefer to return HTMLString than a string

提交回复
热议问题