CustomValidator for dropdownlist...

K

Kristoffer

Hi!
I have an urgent question...
Im using a normal dropdownlist control on my homepage to display a lot of
different values ok...
this dropdownlist is generated dynamicly (since I have different languages
on my homepage).
Now, This part is no problem, the problem comes when I try to use a
customvalidator on my dropdownlist...
I need to use a customvalidator, because one of the dropdownlists only needs
to be filled in if a checkbox has been checked, and if another dropdownlist
has a special value.

Now, I keep getting this strange error message, all the time, something
about that if you add types dynamicly it needs to be the same if you
regenerate the same page again, but it will be, its all hardcoded...
The error page is in swedish, so it makes no sense posting it here...

Any suggestions?? Anyone??

Here comes some example codes, stripped down from my homepage, sorry for the
language, its in swedish, but I think you can understand anyway...

--------- (From my aspx page)
<asp:dropdownlist id="LocalInfoList" runat="server" class="tbflat"
/><asp:CustomValidator
id="err_LocalInfoList1"
Display="None"
Font-Name="verdana"
Font-Size="9pt"
ControlToValidate="LocalInfoList"
OnServerValidate="ChkLocalInfo"
ErrorMessage="Localinfo needs to be filled out!"
runat="server">
</asp:CustomValidator>
-----------
----------(From the sub that generates the dropdownlist content)
LocalInfoList.Items.Clear()
LocalInfoList.Items.Add(new ListItem("Välj ett län:",""))
LocalInfoList.Items.Add(new ListItem("Stockholms
län","Stockholms_l&auml;n"))
LocalInfoList.Items.Add(new ListItem("Uppsala
län","Uppsala_l&auml;n"))
LocalInfoList.Items.Add(new ListItem("Södermanlands
län","S&ouml;dermanlands_l&auml;n"))
LocalInfoList.Items.Add(new ListItem("Östergötlands
län","&Ouml;sterg&ouml;tlands_l&auml;n"))
LocalInfoList.Items.Add(new ListItem("Jönköpings
län","J&ouml;nk&ouml;pings_l&auml;n"))
-----------
----------(The Customvalidator sub)
Sub ChkLocalInfo(source As object, args As ServerValidateEventArgs)
'Kontrollerar så att localinfo har blivit ifylld...
'args.IsValid = False
End Sub
 
K

Kristoffer

Ok, found the error fault...

It was a bug or something in asp.net...
that when I refreshed the page with some content hanging in the air, it just
didnt want to cooperate :(
I just simply retyped the url in my browser, so it loaded the page from
scratch and typed all information again and it worked...

Thanks anyways guys!

/ Kristoffer
 

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

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top