Home All Groups Group Topic Archive Search About

how to capture click event in aspx from placeholder ->control

Author
31 May 2005 1:41 PM
Terry Minvielle via DotNetMonster.com
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


Author
1 Jun 2005 7:09 PM
Phillip Williams
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


Show quoteHide quote
"Terry Minvielle via DotNetMonster.com" wrote:

> 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
> http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-web-controls/200505/1
>