473,320 Members | 1,896 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,320 software developers and data experts.

Problem w/ Validation in UserControl with 2 controls on the same p

I've created a WebUserControl which is Composite Control. It includes
several controls including a few RangeValidator controls and a
ValidationSummary control. The WebUserControl works properly in most
situations, but I've discovered a problem when I place 2 or more of these
controls on the same page. Basically, the ValidationSummary control on each
of the WebUserControls seems to be displaying error messages for
RangeValidators on ALL instances of the WebUserControl on the page, not just
the one it is actually part of!

For testing and discussion purposes, I've created a simpler version o fthe
WebUserControl (i'll call it TestControl) that consists of:
1 TextBox
1 RangeValidator
1 ValidationSummary

I've set the RangeValidator to validate the TextBox for a range of Integers
between 0 and 9. So any single digit will be valid, any double digit (or
more) won't be.

I've then created a Default.aspx page and added the following controls to it:
2 TestControls
1 Button

I then build and browse to the page. And I find the following:

- If I enter a valid number in the TextBox of 1 TestControl and an invalid
number in the TextBox of the other TestControl and click the button, the
ValidationSummary of BOTH TestControls will display the RangeValidator's
error message ONCE.

- If I enter invalid numbers in the TextBoxes of both TestControls and click
the button, the ValidationSummary of BOTH TestControls will display the
RangeValidator's error message TWICE (presumably, once for each TextBox that
is not valid).

I've looked through the client-side script that is generated for the page
and it SEEMS to be ok. The controls on each TestControl are differentiated
in name/ID (i.e. TestControl1_RangeValidator vs TestControl2_RangeValidator,
etc...). Additionally, the problem still occurs if I turn off client-side
validation.

Note: I am using ASP.NET 2.0, but I don't know if this problem is specific
to that version of the framework or not.

Any thoughts?
Dec 28 '05 #1
3 1615
On Wed, 28 Dec 2005 13:39:03 -0800, dei1c3 wrote:
I've created a WebUserControl which is Composite Control. It includes
several controls including a few RangeValidator controls and a
ValidationSummary control. The WebUserControl works properly in most
situations, but I've discovered a problem when I place 2 or more of these
controls on the same page. Basically, the ValidationSummary control on each
of the WebUserControls seems to be displaying error messages for
RangeValidators on ALL instances of the WebUserControl on the page, not just
the one it is actually part of!

For testing and discussion purposes, I've created a simpler version o fthe
WebUserControl (i'll call it TestControl) that consists of:
1 TextBox
1 RangeValidator
1 ValidationSummary

I've set the RangeValidator to validate the TextBox for a range of Integers
between 0 and 9. So any single digit will be valid, any double digit (or
more) won't be.

I've then created a Default.aspx page and added the following controls to it:
2 TestControls
1 Button

I then build and browse to the page. And I find the following:

- If I enter a valid number in the TextBox of 1 TestControl and an invalid
number in the TextBox of the other TestControl and click the button, the
ValidationSummary of BOTH TestControls will display the RangeValidator's
error message ONCE.

- If I enter invalid numbers in the TextBoxes of both TestControls and click
the button, the ValidationSummary of BOTH TestControls will display the
RangeValidator's error message TWICE (presumably, once for each TextBox that
is not valid).

I've looked through the client-side script that is generated for the page
and it SEEMS to be ok. The controls on each TestControl are differentiated
in name/ID (i.e. TestControl1_RangeValidator vs TestControl2_RangeValidator,
etc...). Additionally, the problem still occurs if I turn off client-side
validation.

Note: I am using ASP.NET 2.0, but I don't know if this problem is specific
to that version of the framework or not.

Any thoughts?

Please include your test case.
Of the top of my head, the problem has to do with ids of the composite
controls; they should have their own namespace.

Dec 28 '05 #2
I am not sure whether it's changed in 2.0, but if you look into
WebUIValidation.js script that Microsoft used in 1.1, every ValidationSummary
control will loop through ALL enabled validators on the page - not sure how
to resolve your problem though - if you try to describe what is it that you
are trying to achieve - I may be able to suggest a work around...

"dei1c3" wrote:
I've created a WebUserControl which is Composite Control. It includes
several controls including a few RangeValidator controls and a
ValidationSummary control. The WebUserControl works properly in most
situations, but I've discovered a problem when I place 2 or more of these
controls on the same page. Basically, the ValidationSummary control on each
of the WebUserControls seems to be displaying error messages for
RangeValidators on ALL instances of the WebUserControl on the page, not just
the one it is actually part of!

For testing and discussion purposes, I've created a simpler version o fthe
WebUserControl (i'll call it TestControl) that consists of:
1 TextBox
1 RangeValidator
1 ValidationSummary

I've set the RangeValidator to validate the TextBox for a range of Integers
between 0 and 9. So any single digit will be valid, any double digit (or
more) won't be.

I've then created a Default.aspx page and added the following controls to it:
2 TestControls
1 Button

I then build and browse to the page. And I find the following:

- If I enter a valid number in the TextBox of 1 TestControl and an invalid
number in the TextBox of the other TestControl and click the button, the
ValidationSummary of BOTH TestControls will display the RangeValidator's
error message ONCE.

- If I enter invalid numbers in the TextBoxes of both TestControls and click
the button, the ValidationSummary of BOTH TestControls will display the
RangeValidator's error message TWICE (presumably, once for each TextBox that
is not valid).

I've looked through the client-side script that is generated for the page
and it SEEMS to be ok. The controls on each TestControl are differentiated
in name/ID (i.e. TestControl1_RangeValidator vs TestControl2_RangeValidator,
etc...). Additionally, the problem still occurs if I turn off client-side
validation.

Note: I am using ASP.NET 2.0, but I don't know if this problem is specific
to that version of the framework or not.

Any thoughts?

Dec 29 '05 #3
"Sergey Poberezovskiy" wrote:
I am not sure whether it's changed in 2.0, but if you look into
WebUIValidation.js script that Microsoft used in 1.1, every ValidationSummary
control will loop through ALL enabled validators on the page - not sure how
to resolve your problem though - if you try to describe what is it that you
are trying to achieve - I may be able to suggest a work around...


Yes...that's what I figured out after I posted. My assumption was that the
summary would be specific to the WebUserControl, but it encompasses the
entire page.

My work around was to remove the summary and layout the actual validators to
create a summary which worked fine.

Thanks anyway.
Dec 29 '05 #4

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

Similar topics

1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
1
by: Sundaresan | last post by:
I've a form where I load two user controls dynamically. User Control-1 has a no.of dropdowns and based on the selection I typically populate a datagrid in the user control-2, Also the I could...
0
by: KB | last post by:
Hi guys, How to cause validation inside the UserControl without validating the whole form. I have controls that must be validated on both the form and in the UserControl. But in the UserControl...
2
by: Eric Maia | last post by:
I have two UserControls I am using in a form. These are each also used separately in two other forms. The structure is essentially this: CourseUserControl.ascx - select or enter a course...
0
by: koen | last post by:
Hi! In asp.net (version 1.1) I run into a problem when trying to perform client validation. The error I get on the client-side is : "Error: expected ';'". This problem occurs when I place a...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
7
by: Alon | last post by:
Hi, I'm making my own control which holds some buttons ant textboxes and also has a panel control. in design time i want to drop another controls into the panel that is in my usercontrol. the...
2
by: moondaddy | last post by:
How can I have a page with 2 different groups of controls (where each group of controls contain textboxes, validation controls and a submit button) and each group operate independently? for...
0
by: Nariban Barkan | last post by:
Hi All, I have two UserControls, KK1 and EFT1. Each one has one ScriptManagerProxy and one UpdatePanel . in addition to these, on first control (KK1) there is one button. on second control...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.