Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey there,

I'm trying to create a form using ASP.NET MVC (3). The view uses the Razor engine. I'm trying to add a data attribute to the Form tag :
C#
@using (Html.BeginForm("passwordchange", "account", FormMethod.Post, new { @class = "async", data-success = "account.passwordChangeSuccessfull();" }))

However the engine does not accept the 'minus' sign in the data-success attribute. How can I add such an attribute?

Thanks a lot!
Posted

1 solution

Oh wow,

I just found the answer somewhere online. You need to replace the 'minus' with an underscore.
@using (Html.BeginForm("passwordchange", "account", FormMethod.Post, new { @class = "async", data_success = "account.passwordChangeSuccessfull();" }))

This will do the trick!
 
Share this answer
 
Comments
RaisKazi 29-Nov-11 9:38am    
My 5. That's a really good finding.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900