Gaurav,
I've pasted the appropriate code and HTML below. To answer your
question, yes the Grandson control is a custom control made up of
standard Web controls. I think I'm handling the bubble events properly.
I built a custom eventargs class with custom parameters. If the
OnBubbleEvent catches an event with my custom class, it checks the
custom parameters to see if that particular control should handle it.
If the control should not handle the event, it passes it on up. If the
eventargs are not my custom type, it passes it up. If the event is
handled, the function returns true and the event does not bubble up
further. If this is not correct, please let me know.
Here is the code & HTML. Obviously, watch for line wrap:
Grandpa Control: ViewPhotoGallery.ascx
<%@ Control Language="vb"
Inherits="ViewPhotoGallery"CodeFile="ViewPhotoGall ery.ascx.vb"
AutoEventWireup="false" Explicit="True" %>
<%@ Reference
Control="~/DesktopModules/PhotoAlbum/PhotoGalleryCommentViewer.ascx" %>
<asp:Label ID="lblPhotoTitle" runat="server"></asp:Label>
<asp:Label ID="lblPhotoCaption" runat="server"></asp:Label>
<asp

anel ID="pnlTitleComments" runat="server">
<uc1

hotoGalleryCommentViewer ID="PhotoGalleryCommentViewer1"
runat="server" />
</asp

anel>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Page.MaintainScrollPositionOnPostBack = True
GenerateAlbumPreviews()
End Sub
Sub GenerateAlbumPreviews()
PhotoGalleryCommentViewer1._IsEditable = IsEditable
PhotoGalleryCommentViewer1._PhotoID = CPhoto.ItemID
End Sub
Daddy Control: PhotoGalleryCommentViewer.ascx
<%@ Control Language="VB" AutoEventWireup="false"
CodeFile="PhotoGalleryCommentViewer.ascx.vb"
Inherits="PhotoGalleryCommentViewer" %>
<%@ Reference
Control="~/DesktopModules/PhotoAlbum/PhotoGalleryCommentItem.ascx" %>
<asp:TextBox ID="txtComment" runat="server" Height="70px"
TextMode="MultiLine" Width="150px"></asp:TextBox>
<asp:TextBox ID="txtAuthor" runat="server" Width="150px"></asp:TextBox>
<asp:LinkButton ID="lbClear" CssClass="CommandButton"
runat="server">Clear</asp:LinkButton>
<asp:LinkButton ID="lbSubmit" CssClass="CommandButton"
runat="server">Submit</asp:LinkButton>
<asp

anel ID="pnlComments" runat="server" Width="150px">
</asp

anel>
Public _PhotoID As Integer
Public _IsEditable As Boolean
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles
MyBase.Load
GetComments()
End Sub
Sub GetComments()
pnlComments.Controls.Clear()
Dim CComment As New CommentInfo
Dim Comments As List(Of CommentInfo)
Comments = PGController.GalleryPhotoCommentByPhotoID_qry(_Pho toID)
CRow = New TableRow
CCell = New TableCell
Dim CommentItem As PhotoGalleryCommentItem
For Each CComment In Comments
CommentItem = LoadControl("PhotoGalleryCommentItem.ascx")
CommentItem._ItemID = CComment.ItemID
CommentItem._CommentAuthor = CComment.Author
CommentItem._CommentDate = CComment.PostDate
CommentItem._CommentText = CComment.Comment
CommentItem._IsEditable = _IsEditable
CRow.Cells.Add(CCell)
CTable.Rows.Add(CRow)
Next
pnlComments.Controls.Add(CTable)
CTable = Nothing
CRow = Nothing
CCell = Nothing
CommentItem = Nothing
PGController = Nothing
CComment = Nothing
End Sub
Protected Overrides Function OnBubbleEvent(ByVal source As Object,
ByVal args As System.EventArgs) As Boolean
If args.GetType.Equals(GetType(PhotoGalleryEventArgs) ) Then
'This is a PhotoGallery specific event capture it and process or pass
it up the food chain
Dim PGArgs As PhotoGalleryEventArgs = CType(args,
PhotoGalleryEventArgs)
Select Case PGArgs.Action.ToUpper
Case "REDRAWCOMMENTS"
GetComments()
'Swallow this event
Return True
Case Else
'This is not an event for this procedure pass it on up the food chain
Return False
End Select
Else
'This is not an event for this code. Pass it on up the food chain
Return False
End If
End Function
Grandson Control: PhotoGalleryCommentItem.ascx
<%@ Control Language="VB" AutoEventWireup="false"
CodeFile="PhotoGalleryCommentItem.ascx.vb"
Inherits="PhotoGalleryCommentItem" %>
<asp:Label ID="lblComment" runat="server"></asp:Label>
<asp:Label ID="lblCommentDetails" runat="server"></asp:Label>
<asp:ImageButton ID="ibDeleteComment" runat="server"
ImageUrl="~/images/delete.gif"/>
Public _ItemID As Integer
Public _CommentText As String
Public _CommentDate As Date
Public _CommentAuthor As String
Public _IsEditable As Boolean
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles
MyBase.Load
lblComment.Text = _CommentText
lblCommentDetails.Text = _CommentAuthor & "<br />" & _CommentDate
ibDeleteComment.Visible = _IsEditable
End Sub
'THIS PROC IS EXECUTED ON THE 1ST, 3RD, 5TH, CLICK, BUT NEVER THE 2ND,
4TH, 6TH, ETC.
Protected Sub ibDeleteComment_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ibDeleteComment.Click
Dim PGController As New PhotoGalleryController
If PGController.GalleryPhotoComment_del(_ItemID) > 0 Then
Dim PGEventArgs As New PhotoGalleryEventArgs("RedrawComments", "", "")
RaiseBubbleEvent(Me, PGEventArgs)
Else
Response.Write("<script language='javascript'>alert('An error occured.
The comment was not deleted. Please try again.');</script>")
End If
End Sub