Setting a label = to something kind of as a messagebox

jtr9999

New member
Joined
Jan 18, 2006
Messages
3
Programming Experience
Beginner
Im creating a web application with vb.net in asp and i am trying to have a label appear when the first part of the if statement is false. Here is what i have and it doesnt work.
If listbox1.selectedindex = -1 Then
Label.text = "Please select a name in the listbox"
Label.text.visible = True
Else
 
if this was a winform, it'd work, but since it's asp i dont know why it doesnt work

moved to correct forum
 
hi
I assume that the code you wrote is behind a button click.
As Vis781 already mentioned, you need to make the label visible and not the text of it.
Just set the labels property of visibility to false at "page load" and do the next behind the "button click"-event:

If listbox1.selectedindex = -1 Then
Label.text = "Please select a name in the listbox"
Label.visible = True
Else
 
Back
Top