Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Validator Positioning

Reply
Thread Tools

Validator Positioning

 
 
Angelos Karantzalis
Guest
Posts: n/a
 
      10-27-2004
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:]


 
Reply With Quote
 
 
 
 
Ben Lucas
Guest
Posts: n/a
 
      10-27-2004
I think you are on the right track with using a Table control to organize
the layout of your inputs and validators. Validators are controls just like
any other control and can be placed within TableCell controls. For example
if I have a TableCell control named tableCell and a validator named
myValidator, I can do the following:

tableCell.Controls.Add(myValidator);

You will then still need to add the Validator to the Page.Validators
collection.

--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Angelos Karantzalis" <> wrote in message
news:...
> 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:]
>
>



 
Reply With Quote
 
 
 
 
Angelos Karantzalis
Guest
Posts: n/a
 
      10-27-2004
Unfortunately, a validator can only be added to the Controls collection of
an HtmlForm instance

I'm looking around the ValidationSummary class now, at least that shows the
error mesages in a "prettier" way, e.g. a bulleted list. Whatever happens,
I'll send a post to the group :]

Thanks for taking the time,

Angel
O:]

"Ben Lucas" <> wrote in message
news:ObednZCFdZ30NeLcRVn-...
> I think you are on the right track with using a Table control to organize
> the layout of your inputs and validators. Validators are controls just

like
> any other control and can be placed within TableCell controls. For

example
> if I have a TableCell control named tableCell and a validator named
> myValidator, I can do the following:
>
> tableCell.Controls.Add(myValidator);
>
> You will then still need to add the Validator to the Page.Validators
> collection.
>
> --
> Ben Lucas
> Lead Developer
> Solien Technology, Inc.
> www.solien.com
>
> "Angelos Karantzalis" <> wrote in message
> news:...
> > 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:]
> >
> >

>
>



 
Reply With Quote
 
Angelos Karantzalis
Guest
Posts: n/a
 
      10-27-2004
Well, the ValidationSummary approach worked fine

I've added the control inside a table in the page, and then set the Display
property of all validators to None.
In that way, after validation has finished,any error messages are displayed
inside the ValidationSummary control, which is positioned using the table
that surrounds it ;]

Angel
O:]

"Ben Lucas" <> wrote in message
news:ObednZCFdZ30NeLcRVn-...
> I think you are on the right track with using a Table control to organize
> the layout of your inputs and validators. Validators are controls just

like
> any other control and can be placed within TableCell controls. For

example
> if I have a TableCell control named tableCell and a validator named
> myValidator, I can do the following:
>
> tableCell.Controls.Add(myValidator);
>
> You will then still need to add the Validator to the Page.Validators
> collection.
>
> --
> Ben Lucas
> Lead Developer
> Solien Technology, Inc.
> www.solien.com
>
> "Angelos Karantzalis" <> wrote in message
> news:...
> > 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:]
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts Validator - creditCard validator smrimell@gmail.com Java 4 02-13-2007 08:32 PM
Validator question on positioning tshad ASP .Net 6 06-07-2005 04:09 PM
Validator positioning. Frank Rizzo ASP .Net 3 01-15-2004 12:01 AM
Positioning in dropdownlists Peter J. Hunter ASP .Net 0 01-14-2004 04:13 AM
Positioning Dynamically added controls Harry ASP .Net 1 06-25-2003 06:08 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57