开发者

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"] }) %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜