Quick and dirty asp.net DropDownList selection required validation

by Andrew Jackson 23. October 2006 12:00

I needed to do the usual thing, present a drop down list with the first item as a fake one being something like "-- Choose a Category --"

I jumped straight in and started thinking about custom validation etc etc and lost the will to live very quickly - considering this was just supposed to be a quick knock up project.

Then I found this little snippet, using the RequiredFieldValidator you can specify an InitialValue, put this to be your "-- Choose a Category --" and your away, it won't validate unless it's something other than that!

OK, it's not the most elegant solution, I'd prefer value, or even item being 0 comparison but it does in a push and worth remembering.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.net | Development

My first CodeProject article

by Andrew Jackson 22. October 2006 09:49

I submitted my first article to CodeProject today.

It's one of my favourite sites when looking for articles on new areas I haven't dealt with before so I thought i'd share my technique of using custom attributes and reflection in vb.net.  I demonstrate how to use it to read query string parameters easily into fields without all the repetitive code.

Have a read and see what you think

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Development | VB.net

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About Me

Andrew Jackson

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008,2009 Andrew K. Jackson

RecentComments

Comment RSS