user194076
user194076

Reputation: 9017

alternative to label.visible =true/false

i feel like I'm doing something wrong for a long time already. I usually have some fields, for example: lets take upload control I select a file and then click upload button. So It should tell me whether there was "no file selected" or "uploaded successfully". What I do is: I hide both labels and then I enable them in code behind depending on condition. If I am going to change file again, or I have more states, then my code become messy with a lot of label.visible=true statements. How do you handle this thing?

Thanks!

Upvotes: 1

Views: 682

Answers (1)

Kyle Trauberman
Kyle Trauberman

Reputation: 25684

Use one Label control, then set its .Text property in your code behind based on the message you want to pass to the client.

ASP:

<asp:Label runat="server" ID="lblMessage"></asp:Label>

C#:

lblMessage.Text = "Something happened that you should be aware of.";

Upvotes: 3

Related Questions