[thelist] .NET and MSSQL data validation

Ken Schaefer Ken at adOpenStatic.com
Sun Jul 1 02:32:23 CDT 2007

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Joel D Canfield
Sent: Sunday, 1 July 2007 1:54 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] .NET and MSSQL data validation

> > My understanding of the way the page lifecycle works, 
> > is that .NET will
> > reconstruct the control state on the server side when the 
> > form is posted back, and your validation will run against 
> > what is valid for that particular page state.
> if I understand what you're saying, it's not what I'm looking for. what
> I need is, when they select the office, immediately, the patchport
> select switches to displaying only available ports in the selected
> office.
> I've done it with javascript, but not server side. in a carefully
> controlled environment like this intranet I'm thinking more trips to the
> server would be less good performance for the end user.

Whether or not you use AJAX, you'll have a round-trip to the server unless
you store all available options on the client (and build your <select>
options using javascript alone). I don't advocate this, since you'll need to
recreate the valid options again on the server once the data is posted, in
order to validate the selected options from the user.

For .NET controls, there are "server-side" events. E.g. an <asp:DropDownList>
control has an "onSelectedIndexChanged" event, which (if you configure
autopostback="true") automatically posts the form back to the server. You
just write a little serverside routine that gets the
yourlistbox.selectedValue and uses that to query your database (or some
cached data) to get a list of valid ports. This is then databound to your
second, dependant <asp:DropDownList> control.

This takes about 10 lines of code, and will perform just fine for a small
intranet application.

> am I misunderstanding what you're saying? I'm really feeling in the
> dark; I appreciate your help understanding this.

Happy to send you a sample page of code offlist if you want. 

Otherwise, I've found Stephen Walther's ASP.NET Unleashed books to be the
best single volume you'll find on skilling up on .NET.


More information about the thelist mailing list