0

Question: I have to check the checkbox(which is not part of model) from the action ? If I select the checkbox and submit to post action, then call the view again the checkbox will be checked fine. But how to check it on first place from non-post action please ? Thanks!

public ActionResult Images(string params)
{
//some code
return View(cp);
}

[HttpPost]
public ActionResult Images(string chbx)
{
//some code
}  

Images view:

@using (Html.BeginForm())
{
    @Html.CheckBox("chbx")
} 

I'm using MVC3 by the way.

1 Answer 1

3

do you mean @Html.CheckBox("chbx", true) ?

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

2 Comments

Will this make checkbox always be checked ?
Every pageload, yeah. Do you mean that it is actually part of the model somehow?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.