A
Angelos Karantzalis
Hi guys,
I've a small problem with validators.
I'm building a single .aspx file that handles all my form posts. I need to
be using ASP.NET validators ( or subclasses thereof ), so what i do to
overcome the fact that i don't really know what sort of input controls I'm
working with is this:
1) I've got the form description in xml, so I know all the fields I'm
expecting & their validators with whatever parameters.
2) I dynamically create an HtmlForm component
3) for-each field in my form, I instantiate a home-grown subclass of Input
control, feed it the request parameter & add it to the form.
4) for-each validator in the field, I instantiate the validator and do some
reflection tricks to set the parameters. Then , I add the validator to the
form controls, and I add the validator to the page validators collection.
5) last, I call Page.Validate()
... this all works wonderfully. Validation occurs just like it should, my
only problem is this:
Since, I've added the validators to the form - which is added dynamically
onto the page - the validators aren't positioned anywhere, so the error
message that gets printed, gets printed wherever it wants !
What I though of doing to overcome thins, was to define an <asp:table> on
the page, add a row & cell per control (which is actually invisible ) and
add the validator to the same cell.So, logically, the validator should print
it's message inside the cell I put it ... unfortunately, validators can only
be added to a Form, and I've no idea how to tell the form to render it's
controls inside the table :?
Can anybody help out here ? ( boy, I hate GUIs !!! )
Thanks a lot,
Angel
O:]
I've a small problem with validators.
I'm building a single .aspx file that handles all my form posts. I need to
be using ASP.NET validators ( or subclasses thereof ), so what i do to
overcome the fact that i don't really know what sort of input controls I'm
working with is this:
1) I've got the form description in xml, so I know all the fields I'm
expecting & their validators with whatever parameters.
2) I dynamically create an HtmlForm component
3) for-each field in my form, I instantiate a home-grown subclass of Input
control, feed it the request parameter & add it to the form.
4) for-each validator in the field, I instantiate the validator and do some
reflection tricks to set the parameters. Then , I add the validator to the
form controls, and I add the validator to the page validators collection.
5) last, I call Page.Validate()
... this all works wonderfully. Validation occurs just like it should, my
only problem is this:
Since, I've added the validators to the form - which is added dynamically
onto the page - the validators aren't positioned anywhere, so the error
message that gets printed, gets printed wherever it wants !
What I though of doing to overcome thins, was to define an <asp:table> on
the page, add a row & cell per control (which is actually invisible ) and
add the validator to the same cell.So, logically, the validator should print
it's message inside the cell I put it ... unfortunately, validators can only
be added to a Form, and I've no idea how to tell the form to render it's
controls inside the table :?
Can anybody help out here ? ( boy, I hate GUIs !!! )
Thanks a lot,
Angel
O:]