how to assign the button id dynamically in MVC Action
i declare the button 开发者_开发百科in .aspx its id is btn1
My prob is ,i need to assign the class name of the button and value of the button in action side(i.e in controller)
Use the ViewData dictionary.
public ActionResult Show()
{
ViewData["ButtonClassName"] = "my-class-name";
ViewData["ButtonId"] = "my-id";
View();
}
And in the view:
<%= Html.SubmitButton("name", "text", new { @class = ViewData["ButtonClassName"], id = ViewData["ButtonId"] }) %>
精彩评论