Reputation: 1274
I have a condition based on a session value:
if session("legal_entity")="entity1" then
now, this works well, but only if the value in "session("legal_entity")"
is "entity1"
.
how do I do if the value of session("legal_entity")
is "someText.entity1.someOtherText"
.
this would be to check for the sub string
. I tried the following:
if session("legal_entity").Contains("entity1") then
but of course doesn't work. What solution could I use to simply ask for the sub string inside the session
value?
Upvotes: 1
Views: 937
Reputation: 5030
you can do that after converting to string
like this
if(Convert.ToString(Session["legal_entity"]) == "entity1")
or you can also cast the (session) object
reference to string
:
if (((string)Session["legal_entity"]) == "entity1")
or if you want to use contains
method than do that like this
if (Convert.ToString(Session["legal_entity"]).Contains("entity1"))
{
//your code here
}
Upvotes: 2