473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Validator Positioning

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 ! :D

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:]
Nov 18 '05 #1
3 1652
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" <ak**********@agiltech.gr> wrote in message
news:ep**************@TK2MSFTNGP12.phx.gbl...
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 ! :D

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:]

Nov 18 '05 #2
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" <be*@nospam.solien.nospam.com> wrote in message
news:Ob********************@comcast.com...
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" <ak**********@agiltech.gr> wrote in message
news:ep**************@TK2MSFTNGP12.phx.gbl...
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 ! :D

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:]


Nov 18 '05 #3
Well, the ValidationSummary approach worked fine :D

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" <be*@nospam.solien.nospam.com> wrote in message
news:Ob********************@comcast.com...
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" <ak**********@agiltech.gr> wrote in message
news:ep**************@TK2MSFTNGP12.phx.gbl...
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 ! :D

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:]


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Bryan R. Meyer | last post by:
Hello Everyone, The problem of browser resizing has become an issue for me. While redesigning my webpage, I set the left and right margins to be auto so that my content would be centered. ...
14
by: Harlan Messinger | last post by:
What am I not understanding about the definition of { position: absolute; }? "The box's position (and possibly size) is specified with the 'left', 'right', 'top', and 'bottom' properties. These...
0
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
1
by: rufus | last post by:
Hi, I have 2 validators (RegEx and RequiredField) validating a single field. When one of these validators fires I want it to always render in the same position as the other one. The problem is...
22
by: Trevor Orton | last post by:
Hello, I'm having a slight problem using the W3C html validator and I've reviewed the FAQ's with no luck so hopefully someone here would be kind enough to point me in the right direction. I...
1
by: Charles Harrison Caudill | last post by:
with tables there is a clean and algorithmic way to organize things, but with css which is, once you get it working, much cleaner, I have to tweak and patch and hope and pray and curse before...
3
by: Frank Rizzo | last post by:
My web page is in the FlowLayout Mode. I have 2 validators for a textbox field: a RequiredFieldValidator and RegularExpressionValidator – essentially to make sure that the user entered something...
6
by: tshad | last post by:
I have about 8 validators on my page and I want to show the error message next to or below the field that has the error, but I also want to put 1 message on the top of the page and one on the...
6
by: Mark | last post by:
hi, i'm trying to position something in the top right corner of a container, but i can't seem to figure out how to get it working. here's the html <div class='thumb'><a href='image.jpg'><img...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.