Events in 2 User Controls.

Here's my situation:

 I have a page ( Index.aspx), here i have 2 place holders and i have two different user controls. call them: uc1 and uc2 ( user control)

 Both these user controls have textboxes, and a submit button.

 Here is what i want to do:

 if uc1 button is clicked, i want to check if uc2 textboxes are filled first and call the submit button of the uc2 control -
 and then do a uc1 button click. I am trying to check if the user has login information in the uc2 control and then do a some button click on the uc1 control.

 the same way - if the user has some text information in the textboxes of uc1 and they click on the uc2 submit button - i want
to first finish uc2 button click and only then do a uc1 button submit.

By the way: there are some bussiness logic in each of these button submits.

 I am trying to combine the two on a page level and process both if some information is entered in either of the controls.

I know this has to be done using some bubbling of events, but dont know how to proceed.

Should i create a separate class to handle this, or just do it on the page..


Gurus, Any help is appreciated.


Thanks in advance.
LVL 1
steve_mick972Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mmarinovCommented:
Hi steve_mick972,

i suggest you to create the handler of both button to call same subroutine and pass as parameter to it the button
then in this subroutine you will know which button was hit and do what you want

for validating, you can out requiredfieldvalidators and just use Page.Validate

Regards!
B..M
mmarinov
0
CJ_SCommented:
No event bubbling. Just events, eventhandlers

Assuming your usercontrol looks similar to

Public Class MyControl1
 Inherits System.Web.UI.Control
 Implements INamingContainer

 Public Event SubmitClick As EventHandler
 Protected WithEvents MyButton1 as Button

 Protected Overridable Sub OnSubmitClick(e As EventArgs)
      RaiseEvent SubmitClick(Me, e)
 End Sub
 
 Private Sub MyButton1_OnClick(sender as Object, e as EventArgs) Handles MyButton1.Click
   OnSubmitClick(e)
 End Sub

 Protected Overrides Sub OnInit()
   EnsureChildControls()
 End Sub

 ... your code to initliaize the control...

End Class

Assuming you have two of these instances  declare don your page you can use the OnSubmitClick event of the control to do what you want. In your case you want to validate the controls of the other control. For this you can add a public function to the control which sends you sufficient information to make this check. Also add a function to actually submit the form.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.