tags:

views:

13

answers:

2

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)

+1  A: 

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"] }) %>
Glenn Nilsson
A: 

thank u for ur reply

Instead of maintain the values in view data, is it possible to access the button id directly in controller side?

this should be an edit to your question or a comment on Glenn's answer, not its own answer.
mgroves