Programmatically created web user control events

Discussion in 'ASP .Net Building Controls' started by Jonas, Aug 27, 2003.

  1. Jonas

    Jonas Guest

    I'v made a web user control that I use in one of my .aspx pages. This
    user control is dynamically loaded a number of times depending on the
    content of a ArrayList(stored in the session) containing DataSets.
    Each DataSetscontains the necessary information required to fill the
    user control with data. In each usercontrol there is a delete-button,
    that when clicked will remove a DataSetsentry in the previously
    mentioned ArryList. This will cause the aspx-page on Post Back to load
    one less usercontrol.

    The question: How shall I write the Click event for the
    "delete-button" so that my aspx-page renders with one less user
    Control on PostBack?
    Because the user controls are programmatically loaded I have to load
    them at every post Back, In what event should I do that?

    With kind regards, Jonas
     
    Jonas, Aug 27, 2003
    #1
    1. Advertising

  2. Jonas

    Lucas Tam Guest

    (Jonas) wrote in news:8f2b216b.0308270753.299e9a83
    @posting.google.com:

    > The question: How shall I write the Click event for the
    > "delete-button" so that my aspx-page renders with one less user
    > Control on PostBack?
    > Because the user controls are programmatically loaded I have to load
    > them at every post Back, In what event should I do that?


    Look at the IPostBackEventHandler interface. This interface allows you
    to process postback data BEFORE loading of the controls occurs.

    Here's some code:


    Public Class TestButton
    Inherits Control
    Implements IPostBackEventHandler
    Implements INamingContainer

    Dim sText As String

    Public Overloads Sub RaisePostBackEvent(ByVal eventArgument As
    String) Implements IPostBackEventHandler.RaisePostBackEvent
    If eventArgument = "OK" Then
    sText = "Event Argument OK"
    Else
    sText = "No Argument"
    End If
    End Sub

    Protected Overrides Sub CreateChildControls()
    Dim hlLink As HyperLink = New HyperLink()
    hlLink.ID = Me.UniqueID
    hlLink.Text = "ExecuteLink " & sText

    hlLink.NavigateUrl = Page.GetPostBackClientHyperlink(hlLink,
    "OK")
    Me.Controls.Add(hlLink)
    End Sub
    End Class

    --
    Lucas Tam ()
    Please delete "REMOVE" from the e-mail address when replying.
    http://members.ebay.com/aboutme/coolspot18/
     
    Lucas Tam, Aug 27, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Meade
    Replies:
    9
    Views:
    593
    Rob Meade
    Aug 10, 2004
  2. =?Utf-8?B?anRlbmNhdGU=?=

    Click Events in programmatically created GridView Template

    =?Utf-8?B?anRlbmNhdGU=?=, Jul 28, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    812
    =?Utf-8?B?anRlbmNhdGU=?=
    Jul 28, 2006
  3. Replies:
    1
    Views:
    352
    Teemu Keiski
    Apr 17, 2006
  4. Jonas

    Programmatically created web user control events

    Jonas, Aug 27, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    163
    Lucas Tam
    Aug 27, 2003
  5. Anna Schmidt

    Add events to a programmatically created DG

    Anna Schmidt, Feb 28, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    135
    Marshal Antony
    Mar 29, 2004
Loading...

Share This Page