shahnid k

shahnid k

  • NA
  • 61
  • 14.8k

To check a string contains specific word(here its user).

Jan 12 2017 2:44 AM
Hi,
I need to check a string contains a specific user. If user exist, need to enable button else disable it. I have used two strings. One hard coded and other taking the user name once a user logged in. And i need to check the user name in the list of hardcoded string.
here is what i have written. But its not correct.
Eg:
string username can take "xyzcom\\design.department" then the button should be shown.
    1. string finUser = "xyzcom\\design.department,xyzcom\\basil.jad,xyzcom\\aloshi.alex, xyzcom\\michel felx,xyzcom\\karim.hal,xyzcom\\shah shaan ";  
    2. string username = Page.User.Identity.Name;  //"xyzcom\\design.department" eg
    3. if (finUser.Any(username.Contains))  
    4. {  
    5. Button2.Visible = true;  
    6. }  
    7. else  
    8. {  
    9. Button2.Visible = false;  
    10. }  

Answers (4)