1

I have the following code to include a checkbox to show deleted items as part of a list:

    <input name="DeletedItems" value="ShowDeleted" type="checkbox">
    <label for="showdeleted">Show deleted itmes</label>

This code is located with in the view. My question is: How do I retrieve this value within the controller for this view. I need to retrieve this value in order to to determine whether to show the deleted items or not. Thank you.

2
  • A checkbox is a boolean, so it return true or false, checked or unchecked. Commented Apr 30, 2012 at 20:25
  • Are you doing this on form submission or do you need to do it in a more ajax-y fashion? Commented Apr 30, 2012 at 20:27

1 Answer 1

1

You can use FormCollection object to retrieve check box value..

view:

<:input name="DeletedItems" value="ShowDeleted" type="checkbox">

Controller:

[HttpPost]

public ActionResult YourAction( FormCollection result) {

string CheckBoxValue=result["DeletedItems"];

}

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.