Groups | Blog | Home
all groups > asp.net webcontrols > may 2005 >

asp.net webcontrols : how to capture click event in aspx from placeholder ->control



Terry Minvielle via DotNetMonster.com
5/31/2005 12:00:00 AM
I read with great attention the msdn article on "an Extensive Examination
of User Controls".
However, it did not help me solve the following problem:

I need to populate a place holder with one a several controls which contain
a submit button.
When the parent aspx page loads, I need to load a particular server control
into the placeholder. Then I wish to capture, bubble up, the controls
submit event to the parent.aspx. Using the

If IsPostBack Then
Response.Write(Page.Request.Form.GetValues("__EVENTTARGET")(0))
End If
displays nothing, I guess meening that parent postback event was not
trigered by the submit in the control.

The control contains...

Public Event MySubmit(ByVal sender As Object, ByVal e As System.EventArgs)

Protected Sub btSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btSubmit.Click
RaiseEvent MySubmit(sender, Nothing)
End Sub

Question: How can I, in the parent aspx page tell that btSubmit in control
A was clicked, or control B, etc....

Thanks
Terry

--
Message posted via DotNetMonster.com
Phillip Williams
6/1/2005 12:09:03 PM
To know the control the triggered the event you might pass a string instead
of the eventArg, e.g. Public Event MySubmit(ByVal sender As Object, ByVal str
As String)

I am not sure why you cannot capture the event in the parent form. This
simple demo http://www.societopia.net/webform1.aspx allows you to load one
of two simple controls (inherited from the button control) and then based on
the control clicked it echoes a message indicating which one was clicked.

--
WEBSWAPP Development Inc.
http://www.webswapp.com


[quoted text, click to view]
AddThis Social Bookmark Button