Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to fire a button click event programatically

Reply
Thread Tools

How to fire a button click event programatically

 
 
sripathi sripathi is offline
Junior Member
Join Date: Dec 2009
Posts: 4
 
      01-19-2010
Hi ,

Iam new to VB.Net and iam facing some problems when calling a Button click event from code.

My code consists of an aspx page and a ascx user control . The User control contains a button and a click event is defined for it in the same. Now my requirement is to call the button click event from the aspx page which contains that ascx control.

Since the button is not present in the aspx page directly iam not able to invoke it directly.

please help me in finding the solution

Thanks in advance

Sripathi
 
Reply With Quote
 
 
 
 
JaikeC JaikeC is offline
Junior Member
Join Date: Jan 2010
Posts: 3
 
      01-28-2010
Did you make the user control yourself or is it a third party user control?
 
Reply With Quote
 
 
 
 
JaikeC JaikeC is offline
Junior Member
Join Date: Jan 2010
Posts: 3
 
      01-28-2010
This code is in a user control I made


Code:
Protected Sub ButtonOnUserControl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOnUserControl.Click
		TheCodeToFire()
	End Sub

	Public Sub TheCodeToFire()

		Label1.Text = "Clicked"

	End Sub
This code is in a page that contains the user control

Code:
	Protected Sub ButtonOnWebForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOnWebForm.Click

		Me.WBUC1.TheCodeToFire()

	End Sub
This is the aspx code that defines the user control in the page

in the directives
<%@ Register TagPrefix="uc" TagName="WebUserControl1"
Src="WebUserControl1.ascx" %>

in the form tag

<uc:WebUserControl1 id="WBUC1"
runat="server" />
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fire both event button click and textchanged when button is click and text is changed Amy ASP .Net 0 06-01-2006 02:33 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Datagrid Control 0 05-25-2004 01:45 AM



Advertisments