Reputation: 10412
net mvc3 application I have a checkbox:
<input type="checkbox" id="daStores" name="CheckBox1" onclick="filter()" />
How do I get if its checked or not from the controller?
something like this
public ActionResult GoToPage(string page)
{
bool ischecked = //get the checked status from the view
}
Upvotes: 0
Views: 2194
Reputation: 14219
This is an extremely simplistic (and unrealistic) piece of code I'm going to show, but you have to submit the form to the controller.
HTML:
<form action="MyController/MyAction" method="POST">
<input type="checkbox" id="daStores" name="CheckBox1" onclick="filter()" />
<input type="submit" value="Submit" />
</form>
Controller:
[HttpPost]
public ActionResult MyAction(bool Checkbox1)
{
bool ischecked = Checkbox1;
}
Sounds like you have a very poor understanding of how ASP.NET MVC works, I think you should try working with some introductory tutorials before jumping right in.
http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/intro-to-aspnet-mvc-3
Upvotes: 3