Adding data attributes to MVC3 forms with HtmlHelpers

In a site I’m working on I wanted to add a data attribute, you know, data-*, to a form that was being generated from a controller action in MVC3. So I have the code like this:
@using(Html.BeginFor("Index", "Home", FormMethod.P…


This content originally appeared on Posts on LINQ to Fail and was authored by Posts on LINQ to Fail

In a site I’m working on I wanted to add a data attribute, you know, data-*, to a form that was being generated from a controller action in MVC3. So I have the code like this: @using(Html.BeginFor("Index", "Home", FormMethod.Posts) { <!-- form contents --> } Now I want the form to be opening in a new window, but I’m a good developer and I don’t like littering my code with target="_blank", instead I have some jQuery that I’m using to detect elements that are to go into new windows and adding the attribute programmatically.


This content originally appeared on Posts on LINQ to Fail and was authored by Posts on LINQ to Fail


Print Share Comment Cite Upload Translate Updates
APA

Posts on LINQ to Fail | Sciencx (2011-05-26T00:00:00+00:00) Adding data attributes to MVC3 forms with HtmlHelpers. Retrieved from https://www.scien.cx/2011/05/26/adding-data-attributes-to-mvc3-forms-with-htmlhelpers/

MLA
" » Adding data attributes to MVC3 forms with HtmlHelpers." Posts on LINQ to Fail | Sciencx - Thursday May 26, 2011, https://www.scien.cx/2011/05/26/adding-data-attributes-to-mvc3-forms-with-htmlhelpers/
HARVARD
Posts on LINQ to Fail | Sciencx Thursday May 26, 2011 » Adding data attributes to MVC3 forms with HtmlHelpers., viewed ,<https://www.scien.cx/2011/05/26/adding-data-attributes-to-mvc3-forms-with-htmlhelpers/>
VANCOUVER
Posts on LINQ to Fail | Sciencx - » Adding data attributes to MVC3 forms with HtmlHelpers. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2011/05/26/adding-data-attributes-to-mvc3-forms-with-htmlhelpers/
CHICAGO
" » Adding data attributes to MVC3 forms with HtmlHelpers." Posts on LINQ to Fail | Sciencx - Accessed . https://www.scien.cx/2011/05/26/adding-data-attributes-to-mvc3-forms-with-htmlhelpers/
IEEE
" » Adding data attributes to MVC3 forms with HtmlHelpers." Posts on LINQ to Fail | Sciencx [Online]. Available: https://www.scien.cx/2011/05/26/adding-data-attributes-to-mvc3-forms-with-htmlhelpers/. [Accessed: ]
rf:citation
» Adding data attributes to MVC3 forms with HtmlHelpers | Posts on LINQ to Fail | Sciencx | https://www.scien.cx/2011/05/26/adding-data-attributes-to-mvc3-forms-with-htmlhelpers/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.