It dosent give me an error now but I'm not sure how to use it as a check?
I've tried to use it in an if statement but no positive result:
@foreach(var item in CurrentPage.AncestorOrSelf(2).Descendants("Ansatte")){
string areas = item.fag;
var areaIdArray = areas.Split(new [] {','}, StringSplitOptions.RemoveEmptyEntries).ToString();
if(areaIdArray.Contains(CurrentPage.Id.ToString())){
<p>Show me at this page</p>
}else{
<p>Do not show</p>
}
}
After a good nights sleep i came out with this solution:
@foreach(var item in CurrentPage.AncestorOrSelf(2).Descendants("Ansatte")){
var fag = item.Fag.ToString();
if(fag.Contains(CurrentPage.Id.ToString())){
<p>Show me at this page</p>
}else{
<p>Do not show</p>
}
}
I've no idea if this is the right way to solve it?
You do a ToString after the string split. that should be a tolist
So this should work
@foreach(var item in CurrentPage.AncestorOrSelf(2).Descendants("Ansatte")){
string areas = item.fag;
var areaIdArray = areas.Split(new [] {','}, StringSplitOptions.RemoveEmptyEntries).ToList();
if(areaIdArray.Contains(CurrentPage.Id.ToString())){
<p>Show me at this page</p>
}else{
<p>Do not show</p>
}
}
MNTP - Check string for CurrentPage Id
Hi Guys
I Got theses two areas at my website:
Employees:
Areas:
The employees can be attached to multiple areas with an property of Multinode Treepicker.
When i'm at the page development i would like to show alle employees that have the value og e.g. development (Mads and Sophie).
And my code looks like this right now:
Right now if i output the MNTP It just gives me an list of ID's of the areas that i picked.
1012, 1013
Is it somehow possible to check for the sellected ids?
Something like:
Splitting the string will be safer. Because when check for contains on the string with the value "10" it will match also on this string "210,342"
Something like this :
Dave
Hi Dave
I've tried your suggestion but i get an error like this:
CS1973 : ' string [ ] ' is not a useful method named ' Contains '
My code looks like this:
Hi Mads,
Just typed this from memory so it can contain errors :-)
Maybe you can try this :
Dave
...well memorized anyways :)
It dosent give me an error now but I'm not sure how to use it as a check? I've tried to use it in an if statement but no positive result:
And now it just output "Do not show" :)
Hi again
After a good nights sleep i came out with this solution:
I've no idea if this is the right way to solve it?
Hi Mads
You do a ToString after the string split. that should be a tolist
So this should work
Dave
Hi Dave Well i forgot to mention that my previous post worked, but i was not sure if it was the proper way to do it? Maybe some weak points? :D
But your solution works perfect to - so i go with that solution - thanks for your help I was really stuck on this one :)
It's not entirerly fail safe
Splitting the string will be safer. Because when check for contains on the string with the value "10" it will match also on this string "210,342"
But i guess sense the page id i unique it should not be a problem?
yes page id is unique...But the check matches also non unique id's.
For example your string contains following ids : 1111,2101,4237
The page id of the current item is 101...
If you do a contains it will match because of 2101.
Dave
Ahhh...true...did not see that one :)
Thanks again Dave for your reply :D
is working on a reply...