Web forms - validation controls
Hello,
I noticed something interesting about the Page object, and was wondering if I'm missing something or if this is by design.
When submitting a form (using a button_click event on a codebehind page), you can refer to the controls using this.controlname.Text. But if populating a form with values from a database you'd like to edit (using this.controlname.Text = [database value] in the Page_Load event), you can't use this property, because if you change a field value, this.controlname.Text still points to the original value you set -- you have to use Request.Form["controlname"]. It took me awhile to figure this out, because I'm using a RequiredFieldValidation control, and even though I entered new data into a field the validation control is checking, Page.IsValid is still false. This is because the previous value (that was pulled from the database) was null, and the RequiredFieldValidation control checks the old Page value, not the new Request.Form["controlname"] value. Am I doing something wrong? Has anyone else experienced this, and if so, is there a workaround? or is this by design?
Thank you in advance.
__________________
Steve
iTek Corporation
http://itekcorp.com
|