|
Nazirul, you can ignore this question if you want, but here's another way of writing the same code you have working. I'm sharing this mostly because you can use 1 line to express the same thing that you're using 5 lines for now. It's exactly the same logic, so don't think that either way will be faster than the other, or really better in any way, except if you want more or less lines.
MyMenuItem.Visible = (Trim(Session("AccessLevel")) = "Admin")
When you have an If ???? Then ___ Else ___ block of code, the if clause has to translate into a boolean (true or false) condition. Since you can only set the Visible property to true or false, you can use this short cut. You don't have to, you just can if you want. Your code reads is like If True Then MyMenuItem.Visible = True, so you can get rid of the if then else end if parts.
That applies to just about all of programming. If or when you move from VB.NET to C#, the same thing is true. And in PHP, they have the same concept.
|