473,761 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Raising events from Repeater Template class

Hi,
Am writing a server control which contains a repeater control.

I followed the code outlined by Ra****@discussi ons.microsoft.c om (many
thanks)
on the following thread:

http://groups.google.com/groups?hl=e...oogle%2BSearch

I wish to extend the InstantiateIn code to include a button in the
repeater that raises an event that the containing page will handle.
The problem I have is the containing page doesn't 'see' the event
raised in my RepeaterTemplat e class. I guess I must handle the raised
button event in my main server control class and then re-raise it to
the containing page. The question is how do I do this??

The following shows the RepeaterTemplat e class that my server class
calls:

'============== =============== =============== =====
Class RepeaterTemplat e
Implements ITemplate
Private _templateType As ListItemType
Private _favouriteVisib le As Boolean
Private _btnAddToFavour ites As Button
'declare a public event
Public Event RepeaterButtonC licked As FavouritesEvent Handler
Sub New(ByVal type As ListItemType, _
ByVal favouriteVisibl e As Boolean)
_templateType = type
_favouriteVisib le = favouriteVisibl e
End Sub
Sub InstantiateIn(B yVal container As Control) Implements
ITemplate.Insta ntiateIn
Dim lc As LiteralControl
Dim hyp As HyperLink

Select Case _templateType
Case ListItemType.Se parator
lc = New LiteralControl( "<br>")
container.Contr ols.Add(lc)

Case ListItemType.It em

_btnAddToFavour ites = New Button
_btnAddToFavour ites.Visible = _favouriteVisib le
_btnAddToFavour ites.Attributes ("title") = "Add to your
InfoNet favourites"

_btnAddToFavour ites.Text = "+"
_btnAddToFavour ites.Font.Size = FontUnit.Larger
_btnAddToFavour ites.BorderStyl e = BorderStyle.Non e
_btnAddToFavour ites.BorderColo r =
System.Drawing. Color.Transpare nt
_btnAddToFavour ites.BackColor =
System.Drawing. Color.Transpare nt
_btnAddToFavour ites.Style.Add( "CURSOR", "hand")

AddHandler _btnAddToFavour ites.Click, AddressOf
btnAddToFavouri tes_Click

'add the button control to the repeater template
container.Contr ols.Add(_btnAdd ToFavourites)

'create a new hyperlink control
hyp = New HyperLink

AddHandler hyp.DataBinding , AddressOf
Hyperlink_DataB inding

'add the hyperlink control to the repeater template
container.Contr ols.Add(hyp)

End Select
End Sub
Public Overridable Sub btnAddToFavouri tes_Click(ByVal sender As
System.Object, ByVal e As System.EventArg s)
RaiseEvent RepeaterButtonC licked(Me, New FavouritesEvent Args2)
End Sub

Private Sub Hyperlink_DataB inding(ByVal sender As Object, ByVal e
As System.EventArg s)
Dim hyp As HyperLink
Dim container As RepeaterItem

hyp = CType(sender, HyperLink)
container = CType(hyp.Namin gContainer, RepeaterItem)
hyp.NavigateUrl = CType(DataBinde r.Eval(containe r.DataItem,
"PAGE_URL") , String)
hyp.Text = CType(DataBinde r.Eval(containe r.DataItem,
"PAGE_URL_TEXT" ), String)
End Sub

End Class
' Contains the code for the custom event data class
FavouritesEvent Args.
' Also defines the event handler for the AddToFavourites Clicked event.
Public Class FavouritesEvent Args
Inherits EventArgs
End Class

Public Delegate Sub FavouritesEvent Handler(ByVal sender As Object,
ByVal fe As FavouritesEvent Args)
'============== =============== ============

Any suggestions/code snippets would be most gratefully received!
Nov 21 '05 #1
0 1179

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2107
by: serge calderara | last post by:
Dear all, I have a class wich is raising events as normally it should do. having a form in the same assembly wich is catching those events works fne. Raise events gets catch normaly within the form and I can process what I want based on them. If I try to catch raised events by this class but within a form located in a different assembly, I am not able to
0
1635
by: Pat Sagaser via .NET 247 | last post by:
I'm using a repeater with a dynamic template. I don't know the fields to display (or how many) until runtime. I have everything working except for linking Button events to the repeaters ItemCommand (see below). I've found plenty of examples for doing it using <ItemTemplate> in the aspx file, but I'm stumped when it comes to doing it dynamically at run time. /////////////////////////// .apsx file: <%@ Page language="c#"...
4
1496
by: Joel | last post by:
Hey all- I'm new to asp.net so please bear with me -- I'm attempting to reference the repeater's Container.DataItem outside the repeater object. In other words -- In a seperate sub routine: if the repeater's Container.DataItem == Something -> Do Action. How do I reference the Container.DataItem in by sub routine (And thus outside the repeater object)?
4
1596
by: Dave A | last post by:
I am developing a somewhat complex component at the moment and coincidently I am also reading the Framework Design Guidelines book. After reading the section about event raising I have re-written the way my component raises events to follow the Framework Design Guides verbatim; ie (object sender, EventArgs (or some subclass there of) e). The thing that was not explained is why should I need to cast the sender to 'object' when I know...
2
1697
by: Gman | last post by:
Hi, I have created a usercontrol, a grid control essentially. Within it I have a class: clsGridRecord. I have coded the events such that when a user clicks on the grid, say, the events occur on the parent form. This is fine. The problem occurs when I want to raise an event for a user clicking on one of the clsRecords which are on the grid. So I've placed: Public Event GridRecordClicked(ByVal rec As clsGridRecord,
8
3026
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the way I'm going about doing this might be a little off. I'd appreciate some help. Below is the code I have thus far but I'm not sure how to reference the user control within the foreach loop. <asp:Panel ID="pnlRosterProfile" runat="Server" />
1
1888
by: Asko Telinen | last post by:
Hi all. I ran into quite strange problem concerning the event raising inside FileSystemWatcher Delete event. First, i would like to describe a bit my environment. I have main GUI application, which uses other class libraries. One lib, called Utils.dll contains custom collection implementation. This simple collection just overrides Add and Remove methods to raise
1
4349
by: Dave A | last post by:
I have a problem that I have boiled down to a very simple example. I have a user control that displays a some data from a business object. On one screen I have a collection of these business objects and wish to display the user control multiple times. On this web page I simply bind the repeater to the data source and in the ItemDataBound event dynamically load the user control via "LoadControl()". The user control contains an auto post...
3
3964
by: Emma Middlebrook | last post by:
Hi there, I've been trying to implement a repeater control in an ASP.NET 2 page but I can't seem to get the layout exactly how I want and I'm not sure if it's something that I am doing wrong or maybe the repeater control doesn't have the capabilities...? The page needs to display a custom number of sections that appear the same but have different data..
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.