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.";
精彩评论