dropdown list

Y

Yoshitha

Hi

in my web form i had dropdown list

control and using items property i;ve

added
"--- select Item-----"
0
1
upto 10 numbers.

i also placed required field

validator control for this drop down

list.

when am running my application, if

click on submit button with out

selecting any value in the list then

it is storing 0 value at back end.
how to prompt the user to select the
value from dropdown list.

can anyone tell me how to do this.

thanx in advance.
yoshitha
 
K

Karl Seguin

Yoshita:
The following works:

<asp:ListBox ID="drop" Runat="server">
<asp:ListItem>0</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:ListBox>
<asp:RequiredFieldValidator ID="reqDrop" Runat="server"
ControlToValidate="drop" ErrorMessage="*" />
<asp:button id="btn" Runat="server" />

You'd need to show us some code so we can help you.

HOWEVER. If you are doing this in Firefox (or another browser which isn't
IE), client-side validation isn't going to work. In you button's OnClick
event, you'll need to add

Page.Validate()
If Page.IsValide then
..do your normal stuff here
end if

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top