?
Solved

Events in 2 User Controls.

Posted on 2004-11-16
2
Medium Priority
?
211 Views
Last Modified: 2008-02-26
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.
0
Comment
Question by:steve_mick972
2 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 12599525
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
 
LVL 22

Accepted Solution

by:
CJ_S earned 1000 total points
ID: 12602194
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question