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?
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.