开发者

alternative to label.visible =true/false

开发者 https://www.devze.com 2023-03-16 11:51 出处:网络
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 开发者_如何学JAVAIt s

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 开发者_如何学JAVAIt 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!


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.";
0

精彩评论

暂无评论...
验证码 换一张
取 消