views:

55

answers:

2

Hi all,

How to make a control visibilty to true or false. currently i am setting a panel control visibility like this in code behind. i am comparing the values of Username and UserId. If both the values are same..i am setting panel visibility to false

               if (UserName == UserID))
                {
                    pnl_linkbuttons.Visible = false;
                }

is there any alternative way to set the control visibility in C# from code behind.

Thanks in advance.

+2  A: 
pnl_linkbuttons.Visible = UserName == UserID;
AEMLoviji
HI...thanks for the reply...
karthik
I dont want to make control visibility in this way "pnl_linkbuttons.Visible". is there any other way to achieve the same
karthik
i understand your question now. you have put control inside Panel. And when you want to Make visible of some control you are going to make Visible false of panel. But you want to make UnVisible only control which you want. yes?
AEMLoviji
Don't forget binding...
Dmitry Karpezo
A: 

if you are using asp.net you could use jQuery or javascript, but if youre working in windows forms you pretty much need to use C#.

if you were in silverlight or wpf you could set the visibility using XAML.

try this link for reference if youre in XAML... http://stackoverflow.com/questions/965292/how-can-you-get-a-xaml-textblock-to-collapse-when-it-contains-no-data

or here in MSDN... http://msdn.microsoft.com/en-us/library/system.windows.trigger.aspx

DevilDog74