Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

2 user controls on one page

I will simplify this.

1. I have 2 user controls. They each have one field. For example, last name and phone number
2. Last name and phone are both user controls is required
3. I have a requiredfieldvalidtor in each user control for the lastname textbox and phone textbox
4. Both user controls have a submit button
5. I place both user controls on a page. One top of the page, the other one below it.
Now

Since both fields are required and I have required field validator on both fields...I enter something in Phone textbox BUT nothing in lastname (because this is on UC1). I click sumbit but the fieldvalidator in UC1 gets activated (the one for last name).

I need the validators to only work for that specific user control. How can I do this?

Avatar of GlobaLevel
GlobaLevel
Flag of United States of America image

Since both fields are required and I have required field validator on both fields...I enter something in Phone textbox BUT nothing in lastname (because this is on UC1). I click sumbit but the fieldvalidator in UC1 gets activated (the one for last name).



>>>Im sorry I read this a few times and I still dont get whats going on...from what I read the filedvator should be activated...and UC1 is just the tag that you registered at the top of the page...
Avatar of Camillia

ASKER

sorry, bad english :)

I have 2 user controls: UC1 and UC2. Both are on xxx.aspx page.
UC1 has a required filed phone
UC2 has a required field last name
Both UC1 and UC2 have a submit button.

I enter something in phone. Nothing in last name. I click submit button in UC1. At this point, submit should should work. It should NOT validate last name since last-name is on user contorl 2 (UC2). But it does validate last-name....

They are 2 separate user controls with 2 separate buttons so validation should occur within their own "space"...UC1 button should NOT validate UC2's fields .
okay so I guess we are getting crossover...then you can you check 2 things...one that required fieled validator in the .ascx page and see that uc1 and uc2 arent sharing the same thing...check any .aspx or .ashx page that the user control may call in the process...
so, there shouldnt be any cross over ... i mean...this is NOT nomal behavior? I thought maybe this is how user contols work and i need to code something in code behind instead of using required field validators
ASKER CERTIFIED SOLUTION
Avatar of GlobaLevel
GlobaLevel
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial