How to retrieve checked value in checkbox property with Razor?
Hello again.
I have a Checkbox list data type which I created it in order to manage and control the categories in my magazine. I want to use it to my archieve pages. So each page I create I check for him the right category - gadgets / photography / etc
My question is: when I want to display the archieve pages - how can I retrieve the checked value from the Checkbox property?
This is actually what I'd like to do - to retrieve the checked value of the current page (which I don't know how to do - I tried to write something like Magazine_Category = Model.MagazineCategories (this the property ID) and then
However, Model.MagazineCategories apparently do not retrieve the checked value ...
What I need is the Text - becasue then it will be easy to manage the category. Also the ID is fine, but it will be much better and much more clear to retrieve the text - because each text is the category - which I declared.
So, how can I access / retrieve the checked value of the current page ?
This seems a bit odd? If you want to get the property value of a checkbox property
int checkBoxValue;
@if(Model.HasValue("Checkboxes")) //Check the property is avaliable { Int32.TryParse(@Model.GetPropery("Checkboxes").Value.ToString(), out checkBoxValue); <ul>
Yes, Thanks! Work. But now I have another question:
When I display the magazine I want to display it by categories, so for example once I dislay the "gadgets" I want to exclude all the nodes with the Photogrpahy Property and when display the "Photography" I want to exclude the "Gadgets". I wanted to use the "where" however, it's a proble because all the the Childrens (pages) are mix under one node (Gadgets + Photography) so actually I need to do it during the foreach look - the question is if I can sort the childrens before? It's mean - to get the property (category) of each children in the node before the loop?
How to retrieve checked value in checkbox property with Razor?
Hello again.
I have a Checkbox list data type which I created it in order to manage and control the categories in my magazine. I want to use it to my archieve pages. So each page I create I check for him the right category - gadgets / photography / etc
My question is: when I want to display the archieve pages - how can I retrieve the checked value from the Checkbox property?
This is actually what I'd like to do - to retrieve the checked value of the current page (which I don't know how to do - I tried to write something like Magazine_Category = Model.MagazineCategories (this the property ID) and then
However, Model.MagazineCategories apparently do not retrieve the checked value ...
What I need is the Text - becasue then it will be easy to manage the category. Also the ID is fine, but it will be much better and much more clear to retrieve the text - because each text is the category - which I declared.
So, how can I access / retrieve the checked value of the current page ?
Thanks.
Checkbox property can be retrived by the following code:
I advise you to take a look in this razor sample project really good work
Thanks!
Work.
Is it possible also w/o a loop? Just to take the current? (which checked)
Yes
I think you can use only
this will give you only the selected value.
This seems a bit odd? If you want to get the property value of a checkbox property
int checkBoxValue;
@if(Model.HasValue("Checkboxes")) //Check the property is avaliable
{
Int32.TryParse(@Model.GetPropery("Checkboxes").Value.ToString(), out checkBoxValue);
<ul>
if(checkBoxValue) //SHOULD BE TRUE/FALSE
{
<li>@item</li> //CHECKED
}
else
{
//NOT CHECKED
}
</ul>
}
Something like the above? Charlie :)
Yes, Thanks! Work. But now I have another question:
When I display the magazine I want to display it by categories, so for example once I dislay the "gadgets" I want to exclude all the nodes with the Photogrpahy Property and when display the "Photography" I want to exclude the "Gadgets". I wanted to use the "where" however, it's a proble because all the the Childrens (pages) are mix under one node (Gadgets + Photography) so actually I need to do it during the foreach look - the question is if I can sort the childrens before? It's mean - to get the property (category) of each children in the node before the loop?
I think you can use the "NodebyId" method in order to get the children from a specific category.
Moran, where do you get the id for the NodyById from and what happens if the node is recreated?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.