Привет, вы хотите исчезнуть панели инструментов, а вкладки все еще просматриваются, вы должны написать следующий код:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
></android.support.v7.widget.Toolbar>
И если вы хотите скрыть TabLayout, используйте scrollFlags в блоке TabLayout
app:layout_scrollFlags="scroll|enterAlways"
It forces the field to be included if it's unchecked. If you uncheck a check box it doesn't get sent as part of the page - they are only sent if they're checked, and then there's a value of true. The hidden field ensures that false will be send if the check box is unchecked, as the hidden field is always sent.
If a CheckBox is not checked, then it will not be included in the form submission. So this "feature" gives you a result for every CheckBox. Those that are not checked will be simply "false".
I have implemented my own CheckBox helper functions that work differently. Most of the time I don't want just true or false, but just a collection of the values of the checked boxes. It's great for selecting certain items by their id on which to perform an action. I don't want the unchecked items even in the list.
You can take a look at the source code for the html extensions and use a similar structure to create your own CheckBox methods.
http://aspnet.codeplex.com/sourcecontrol/changeset/view/23011?projectName=aspnet#288010
I would post mine, but I'm not using the standard HtmlHelper class, so it would probably be more confusing. I did add a value parameter to my CheckBox functions so that I can use a specific id value instead of "true" or "false".
Now whenever I check the box and access Request.Form["ForSale"], I get the ridiculous answer of "true,false". Am I supposed to parse that?
Try this:
var ForSale = Convert.ToBoolean(Request.Form.GetValues("ForSale").First());
UPDATED:
What if in the next MVC build it will return the value in the revers order "false, true"? ... – Mastermind
var ForSale = Request.Form.GetValues("ForSale")
.Select(x => x.ToUpperInvariant()).Contains("TRUE");
// or
// FormatException can be thrown from Convert.ToBoolean()
var ForSale = Request.Form.GetValues("ForSale")
.Select(x => Convert.ToBoolean(x)).Contains(true);
Here's how I've done it in one of my apps. Frustrating, but it seems to work.
public virtual ActionResult Edit(int id, FormCollection values)
{
SomeObject dbData = _repository.GetSomeObject(id);
try
{
UpdateModel(dbData);
if (values.GetValues("CheckBoxId").Contains("true"))
dbData.SomeBooleanProperty = true;
else
dbData.SomeBooleanProperty = false;
_repository.Save();
Session["Success"] = "Successfully edited the part.";
return RedirectToAction("Index");
}
catch
{
// Handle validation errors here
return View(new SomeObjectFormViewModel(dbData));
}
}
Hope this helps. If you've got any follow-up questions, just leave a comment and I'll update my answer accordingly.
try
request.form ["chkBoxes"]. Replace ("false", ""). Split (new char [] {','}, stringsplitoptions.removeemptyentries);
Я думаю, что самым чистым решением будет следующее:
(bool)formCollection["key"].ConvertTo(typeof(bool))