Solved

How to have one onclick event execute the second onclick event

Posted on 2006-11-03
3
195 Views
Last Modified: 2012-08-13
How would I have a button onclick event call another onclick event. It's hard to explain, but the onclick event arguments of one button is not the same as the onclick arguments of the other button due to each of the buttons being within different controls. I need the first button to act as an agent of the second button.

In the code behind, the first button has an argument of:

      Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
           Execute the second button
        End Sub

The second button has an event argument of:

      Protected Sub Button2_Click(ByVal sender As Object, ByVal e As Control.ViewUpdatedEventArgs)
           Do something...
        End Sub

I need the first button to execute the second.

Thanks

0
Comment
Question by:barnesco
3 Comments
 
LVL 27

Accepted Solution

by:
Sammy earned 500 total points
ID: 17872445
Try using RaiseEvent EventName(arg1,arg2)
take a look here
http://www.codeproject.com/aspnet/ToggleControls.asp

HTH
0
 
LVL 1

Expert Comment

by:bthews
ID: 17883564
Forgive my ignorance of the situation, but I can't think of an example of why you would need to do this, at least on the serverside.

All you are doing in the click event is capturing the event, correct?
So if they click button1, then you want to execute some code, right?

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
           MyButtonTwoCodeMethod();
End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As Control.ViewUpdatedEventArgs)
           MyButtonTwoCodeMethod();
           AnyOtherMethodIwant();
End Sub


Can't you just call the same code when the button1 is clicked, instead of actually "clicking" the other button as well?
0
 

Author Comment

by:barnesco
ID: 18047040
Sorry for the late response.

I'm using a suite of proprietary controls (Telerik) where I need a button control (ByVal e As System.EventArgs) to call the proprietary telerik button command (ByVal e As Control.ViewUpdatedEventArgs). What I don't know is the syntax of "MyButtonTwoCodeMethod()" as in:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
           MyButtonTwoCodeMethod();
End Sub


Thanks.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now