Bill Henderson
asked on
classic aspvb syntax question
Hi,
I have an old asp site that I need to modify. We have a menu item that shows under a certain condition with a usertype field:
and then we show the menu item.
We recently modified a database field so that a single user record can be assigned multiple types in a comma delimited list. So instead of UserType=1, for our condition, we need to check if Session("UserType") contains 1 in a comma delimited list.
assuming users will have values like 1,7,8 or 1,3,7 how can I scan and confirm a "contains" condition in asp vb?
Thank you
Bill
I have an old asp site that I need to modify. We have a menu item that shows under a certain condition with a usertype field:
<% IF Session("UserType") = 1 OR Session("UserType") = 7 THEN %>
and then we show the menu item.
We recently modified a database field so that a single user record can be assigned multiple types in a comma delimited list. So instead of UserType=1, for our condition, we need to check if Session("UserType") contains 1 in a comma delimited list.
assuming users will have values like 1,7,8 or 1,3,7 how can I scan and confirm a "contains" condition in asp vb?
Thank you
Bill
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
Gary`s is the quickest one - but hard to read and you have always to add the "," before and after your session variable. This will work for any number but it could be not as error save as Padas/my solution due to the extras you have to add.
Padas solution is the right one in terms of best practices as it creates the array with the distinct values and then runs the compare.
My extension to Padas solution just make it usable for any check you want to run - check for 5 or 10 or ...
Just my 2ct
Rainer
Gary`s is the quickest one - but hard to read and you have always to add the "," before and after your session variable. This will work for any number but it could be not as error save as Padas/my solution due to the extras you have to add.
Padas solution is the right one in terms of best practices as it creates the array with the distinct values and then runs the compare.
My extension to Padas solution just make it usable for any check you want to run - check for 5 or 10 or ...
Just my 2ct
Rainer
ASKER
OK thx - I have another question related to this that I will post right now, to not abuse my points. =)
ASKER
Thanks for the help
Don't actually see a problem with adding a comma, it just makes the number distinct to do an instr check
ASKER
So truly if we get to 10 user types, we need to use Pradas or Rainer's solutions?