I am trying to create a custom html button on my page using this
public static class HtmlButtonExtension { public static MvcHtmlString Button(this HtmlHelper helper, string text, IDictionary<string, object> htmlAttributes) { var builder = new TagBuilder("button"); builder.InnerHtml = text; builder.MergeAttributes(htmlAttributes); return MvcHtmlString.Create(builder.ToString()); } }
When I click this button, I want to pass the record identifier to my action
Below is what I added to razor mode
@ Html.Button ("Delete", new {name = "CustomButton", recordID = "1"})
But I could not display this button, and it throws erros
'System.Web.Mvc.HtmlHelper<wmyWebRole.ViewModels.MyViewModel>' does not contain a definition for 'Button' and the best extension method overload 'JSONServiceRole.Utilities.HtmlButtonExtension.Button(System.Web.Mvc.HtmlHelper, string, System.Collections.Generic.IDictionary<string,object>)' has some invalid arguments
Can someone help me determine the actual error
source share