473,554 Members | 2,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validate multiple Panels

I have a form that i've split up into multiple asp:panels, each panel
has a number of validators which work correctly.

At on the last panel, i want to commit the data collected to a
database. I figured since all the panel data is still being sent
through the postbacks, instead of using Sessions, or HttpContext, I
could just take the values from the textboxes.

This all works fine, except for security. I realized that I could
inject new values into the POST data. Once a page has been validated,
its not validated again before committing to the database, in essence,
making the validators on the other panels useless.

To fix this, before committing, I would get a list of all the
validators on the page, re-validate each, and if all of them were
still valid, commit. That way any injected POST variables would
become invalid and the commit would not happen. Code:

foreach (IValidator validator in Page.Validators )
{
validator.Valid ate();
if (!validator.IsV alid)
return;
}

This gets a list of all the validators across all the panels, but
Validate() does not update the IsValid property and the injected
variables are allowed through. ... How come Validate() is not
updating? Testing, if I set a textbox.text = "" after it initally
validates, the textboxes custom validator which checks for length 5
validates to true, even though it is not.

Any help would be greatly appreciated!

Jul 11 '07 #1
4 2584
the validators only update themselves. to test if valid the page does
the same loop you do.

you could make one custom validator that does the loop, then
Page.IsValid would call this one.

-- bruce (sqlwork.com)
Brybot wrote:
I have a form that i've split up into multiple asp:panels, each panel
has a number of validators which work correctly.

At on the last panel, i want to commit the data collected to a
database. I figured since all the panel data is still being sent
through the postbacks, instead of using Sessions, or HttpContext, I
could just take the values from the textboxes.

This all works fine, except for security. I realized that I could
inject new values into the POST data. Once a page has been validated,
its not validated again before committing to the database, in essence,
making the validators on the other panels useless.

To fix this, before committing, I would get a list of all the
validators on the page, re-validate each, and if all of them were
still valid, commit. That way any injected POST variables would
become invalid and the commit would not happen. Code:

foreach (IValidator validator in Page.Validators )
{
validator.Valid ate();
if (!validator.IsV alid)
return;
}

This gets a list of all the validators across all the panels, but
Validate() does not update the IsValid property and the injected
variables are allowed through. ... How come Validate() is not
updating? Testing, if I set a textbox.text = "" after it initally
validates, the textboxes custom validator which checks for length 5
validates to true, even though it is not.

Any help would be greatly appreciated!
Jul 11 '07 #2
On Jul 11, 12:41 pm, bruce barker <nos...@nospam. comwrote:
the validators only update themselves. to test if valid the page does
the same loop you do.

you could make one custom validator that does the loop, then
Page.IsValid would call this one.

-- bruce (sqlwork.com)

Brybot wrote:
I have a form that i've split up into multiple asp:panels, each panel
has a number of validators which work correctly.
At on the last panel, i want to commit the data collected to a
database. I figured since all the panel data is still being sent
through the postbacks, instead of using Sessions, or HttpContext, I
could just take the values from the textboxes.
This all works fine, except for security. I realized that I could
inject new values into the POST data. Once a page has been validated,
its not validated again before committing to the database, in essence,
making the validators on the other panels useless.
To fix this, before committing, I would get a list of all the
validators on the page, re-validate each, and if all of them were
still valid, commit. That way any injected POST variables would
become invalid and the commit would not happen. Code:
foreach (IValidator validator in Page.Validators )
{
validator.Valid ate();
if (!validator.IsV alid)
return;
}
This gets a list of all the validators across all the panels, but
Validate() does not update the IsValid property and the injected
variables are allowed through. ... How come Validate() is not
updating? Testing, if I set a textbox.text = "" after it initally
validates, the textboxes custom validator which checks for length 5
validates to true, even though it is not.
Any help would be greatly appreciated!
Thanks Bruce, that is essentially what I am doing, more specifically,
my problem is that validator.Valid ate() is not actually re-
validating. Even if the validator should no longer validate,
validator.isVal id stays true.

Jul 11 '07 #3
On Jul 11, 1:31 pm, Brybot <bryanr...@gmai l.comwrote:
On Jul 11, 12:41 pm, bruce barker <nos...@nospam. comwrote:
the validators only update themselves. to test if valid the page does
the same loop you do.
you could make one custom validator that does the loop, then
Page.IsValid would call this one.
-- bruce (sqlwork.com)
Brybot wrote:
I have a form that i've split up into multiple asp:panels, each panel
has a number of validators which work correctly.
At on the last panel, i want to commit the data collected to a
database. I figured since all the panel data is still being sent
through the postbacks, instead of using Sessions, or HttpContext, I
could just take the values from the textboxes.
This all works fine, except for security. I realized that I could
inject new values into the POST data. Once a page has been validated,
its not validated again before committing to the database, in essence,
making the validators on the other panels useless.
To fix this, before committing, I would get a list of all the
validators on the page, re-validate each, and if all of them were
still valid, commit. That way any injected POST variables would
become invalid and the commit would not happen. Code:
foreach (IValidator validator in Page.Validators )
{
validator.Valid ate();
if (!validator.IsV alid)
return;
}
This gets a list of all the validators across all the panels, but
Validate() does not update the IsValid property and the injected
variables are allowed through. ... How come Validate() is not
updating? Testing, if I set a textbox.text = "" after it initally
validates, the textboxes custom validator which checks for length 5
validates to true, even though it is not.
Any help would be greatly appreciated!

Thanks Bruce, that is essentially what I am doing, more specifically,
my problem is that validator.Valid ate() is not actually re-
validating. Even if the validator should no longer validate,
validator.isVal id stays true.
Heres a code snippet:

private void Button1_Click(o bject sender, System.EventArg s e)
{
this.TextBoxVar .Text = "";
this.CustomVali datorCheckLengt h.IsValid = false;
Page.Validate() ;
if (Page.IsValid)
Response.Write( "Valid");
}

private void CustomValidator CheckLength_Ser verValidate(obj ect source,
System.Web.UI.W ebControls.Serv erValidateEvent Args args)
{
if (this.TextBoxVa r.Text.Length 5)
args.IsValid = true;
else
args.IsValid = false;
}

If I enter a value of length greater then 5 then submit form, this
always evaluates to true, even when I specifically set it so that it
should not validate...

Jul 11 '07 #4
On Jul 11, 2:26 pm, Brybot <bryanr...@gmai l.comwrote:
On Jul 11, 1:31 pm, Brybot <bryanr...@gmai l.comwrote:
On Jul 11, 12:41 pm, bruce barker <nos...@nospam. comwrote:
the validators only update themselves. to test if valid the page does
the same loop you do.
you could make one custom validator that does the loop, then
Page.IsValid would call this one.
-- bruce (sqlwork.com)
Brybot wrote:
I have a form that i've split up into multiple asp:panels, each panel
has a number of validators which work correctly.
At on the last panel, i want to commit the data collected to a
database. I figured since all the panel data is still being sent
through the postbacks, instead of using Sessions, or HttpContext, I
could just take the values from the textboxes.
This all works fine, except for security. I realized that I could
inject new values into the POST data. Once a page has been validated,
its not validated again before committing to the database, in essence,
making the validators on the other panels useless.
To fix this, before committing, I would get a list of all the
validators on the page, re-validate each, and if all of them were
still valid, commit. That way any injected POST variables would
become invalid and the commit would not happen. Code:
foreach (IValidator validator in Page.Validators )
{
validator.Valid ate();
if (!validator.IsV alid)
return;
}
This gets a list of all the validators across all the panels, but
Validate() does not update the IsValid property and the injected
variables are allowed through. ... How come Validate() is not
updating? Testing, if I set a textbox.text = "" after it initally
validates, the textboxes custom validator which checks for length 5
validates to true, even though it is not.
Any help would be greatly appreciated!
Thanks Bruce, that is essentially what I am doing, more specifically,
my problem is that validator.Valid ate() is not actually re-
validating. Even if the validator should no longer validate,
validator.isVal id stays true.

Heres a code snippet:

private void Button1_Click(o bject sender, System.EventArg s e)
{
this.TextBoxVar .Text = "";
this.CustomVali datorCheckLengt h.IsValid = false;
Page.Validate() ;
if (Page.IsValid)
Response.Write( "Valid");

}

private void CustomValidator CheckLength_Ser verValidate(obj ect source,
System.Web.UI.W ebControls.Serv erValidateEvent Args args)
{
if (this.TextBoxVa r.Text.Length 5)
args.IsValid = true;
else
args.IsValid = false;

}

If I enter a value of length greater then 5 then submit form, this
always evaluates to true, even when I specifically set it so that it
should not validate...
Whew! Figured it out.

Even though I am looping through each Validator, the panel it is in
has to be set to visible=true for the validator to be forced to run.
Therefore, as in the above Button1 Click event, if I add
this.panelX.Vis ible = true; for each panel that contains a validator,
they we re-validate.

Awesome!

Jul 11 '07 #5

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

Similar topics

0
1625
by: flupke | last post by:
Hi, i need to develop a gui which will load several "windows" depending on what the users selects in the menu and i thought i could accomplish this with panels. What i'm trying to do to test this is load an initial panel and then when the user hits a button load a second panel. This doesn't seem to work. 1. what's the appropriate way of...
8
1869
by: Steve McLellan | last post by:
Hi, I'm trying to add panels to a parent panel programatically. I'd like them to all take up an equal amount of the parent form as it's resized etc. Using Docking::Fill obviously causes one panel to expand to fill the entire parent, and I can't get a satisfactory result using Anchor - the leftmost controls start to take more than their fair...
1
7652
by: pfnus | last post by:
Hi, I want to display different forms when the buttons are clicked and all the forms are having different controls on it. So instead of adding new windows forms to the project, i enlarged the form and used many panels on the same form, which i think is easier to manage. However, i am having problems. Should i need to put the panels on the...
3
2227
by: Jonas | last post by:
Hi! I have aspx-page where I use multiple panels to make room for more controls than would otherwise fit onto one page. On submit, the controls on all panels, visible or not, should be validated with the ASP.NET validators, and if the page is valid, it is sent to the database in one transaction. But it seems that only the controls on the...
9
6654
by: B-Dog | last post by:
I have a form that has about 10 text boxes on it, they all have to be filled out before submitting is there a quick way to make sure that none are null or do I have to call out each textbox? Say something like textbox1 through textbox10? Thanks
6
1587
by: Willem | last post by:
I have got a very simple javascript which compares about 8 controls in pairs of two. i.e. maxA - minA <= 25. Now I would like it to be triggered for validation (before submit?) and cancel the submit if neccessary. Very easy to do if it were plain HTML. No idea how to implement this in ASP.NET 2 though. Can someone please point me in the right...
6
15628
by: dream2rule | last post by:
Hello All, I am trying to validate multiple checkboxes whose values are stored in an array using php. I have been trying from a really long time but nothing's working out. Can anyone help? Here's the code: <form id="create_user" name="create_user" method="post" action="creating_database.php" onsubmit="return...
3
7979
by: DragonLord | last post by:
Ok here is the situation in detail. Single form with multiple items on it, 4 of which are panls that contain radio butons. Each panel loads it's radio buttons from a list of items in a sql database table. This is the easy part. Hard part is this. The panels are not ll in a row on the form so i can't just put the into a single group box...
2
1648
by: jyaseen | last post by:
if i insert multiple e-mail id in To textbox like below , how can i validate the email ids. <user1@example.com>, <user1@example.com>, "User 3" <user3@example.com>, "User 4" <user4@example.com>, in google if we insert ids like above or comma separated , it will accept . anybody know the coding to validate this in PHP
0
7600
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8042
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7889
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5436
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3560
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1134
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
841
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.