Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Programmatically created web user control events

Reply
Thread Tools

Programmatically created web user control events

 
 
Jonas
Guest
Posts: n/a
 
      08-27-2003
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
 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      08-27-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (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 ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Click Events in programmatically created GridView Template =?Utf-8?B?anRlbmNhdGU=?= ASP .Net 0 07-28-2006 08:35 PM
Events not firing in datagrid with programmatically created columns J.ShepherdII@gmail.com ASP .Net Datagrid Control 1 04-17-2006 02:27 PM
Events for programmatically created controls?? how.. Rob Meade ASP .Net 9 08-10-2004 02:40 PM
Add events to a programmatically created DG Anna Schmidt ASP .Net Web Controls 1 03-29-2004 05:02 AM
Programmatically created web user control events Jonas ASP .Net Building Controls 1 08-27-2003 08:17 PM



Advertisments