Professional Web Applications Themes

Programmatically created web user control events - ASP.NET Building Controls

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 ...

  1. #1

    Default Programmatically created web user control events

    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 Guest

  2. #2

    Default Re: Programmatically created web user control events

    [email]jopconsignit.se[/email] (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 (REMOVEnntprogers.com)
    Please delete "REMOVE" from the e-mail address when replying.
    [url]http://members.ebay.com/aboutme/coolspot18/[/url]
    Lucas Tam Guest

Similar Threads

  1. Maintaining state in programmatically created composite user controls
    By mark.norgate@gmail.com in forum ASP.NET Building Controls
    Replies: 3
    Last Post: March 23rd, 11:20 AM
  2. Programmatically Get to User Control Properties
    By Newbie in forum ASP.NET Building Controls
    Replies: 2
    Last Post: July 14th, 12:55 PM
  3. events for dynamically created buttons nested in custom control
    By Kasabaarde Sumta in forum ASP.NET Building Controls
    Replies: 0
    Last Post: October 29th, 03:15 PM
  4. Programmatically create buttons from user control
    By Jonah Olsson in forum ASP.NET Building Controls
    Replies: 1
    Last Post: December 7th, 09:39 PM
  5. Replies: 0
    Last Post: August 11th, 05:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139