I have a Html button as follows:
<%=Html.Button("javascript:onSave();", CommonResource.Save, "SaveButton")%>
Where:
parameter1 - action
parameter2 - name
parameter3 - id
How can I add parameter for CSS class? I tried doing this:
<%=Html.Button("javascript:onSave();", CommonResource.Save, "SaveButton",new { @class="save" })%>
but that does not work. I only get the looks but no action is performed.
You need to look at your implementation of
Html.Buttonas it isn’t a standard HtmlHelper.It probably doesn’t have a parameter for htmlAttributes, in which case you could use this implementation, which does!