all groups > vb.net controls > september 2004 >
You're in the

vb.net controls

group:

HOWTO: Receive User Control Button Click In Parent Page



HOWTO: Receive User Control Button Click In Parent Page Dan Sikorsky
9/29/2004 8:16:26 AM
vb.net controls: How do you act on a user control's (.ascx) button click event in the
containing page (.aspx) ?

Should event bubbling be considered?

Does this even make sense to try and do?

Should the user control's button click just 'submit' the page and then let
the Page_Load event get the user control data from the Request.Form or
Request.Querystring object?


--
Thank you kindly,
Dan Sikorsky BAB, BScE, MSC

Re: HOWTO: Receive User Control Button Click In Parent Page bill
10/12/2004 4:50:13 PM
I think you can use a delegate.
http://aspnet.4guysfromrolla.com/articles/031704-1.aspx#postadlink


[quoted text, click to view]

Re: HOWTO: Receive User Control Button Click In Parent Page Dan Sikorsky
10/19/2004 7:24:54 AM
Here's a simple solution:
1. In the Login1.acsx.vb file put
Public ReadOnly Property UserID() As String

Get

UserID = txtUserID.Text

End Get

End Property

Protected Overrides Function OnBubbleEvent(ByVal source As Object, ByVal
args As System.EventArgs) As Boolean

RaiseBubbleEvent(Me, args)



End Function

2. In the WebForm1.aspx file put the following to copy a textbox on the
usercontrol to a label on the parent form, when a button on the usercontrol
is clicked.
Protected Overrides Function OnBubbleEvent(ByVal source As Object, ByVal
args As System.EventArgs) As Boolean

If source.id = "Login1" Then

If source.UserID = "Simple" Then

Label1.Text = source.UserID

End If

End If

End Function

[quoted text, click to view]

AddThis Social Bookmark Button