Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Bubbling Up Events

Reply
Thread Tools

Bubbling Up Events

 
 
a
Guest
Posts: n/a
 
      11-09-2003
Hi,

I have a CustomControl that is essentially a WebControls.Table (TEKTable).
You tell it how many columns, and it renders UserControls (passed in via an
ArrayList) in that number of columns, and however many rows it takes.

My UserControls typically have buttons on them. I can't seem to get the
event to bubble up. TEKTable is in a UserControl project, so it won't
always be aware of the types located in the web app. SO, when I try to add
an event handler to the event of the UserControl, it won't do it. And I
can't do a CType, because I don't want to be able to use this table to host
many different controls.

How can / should I set this up? Do I need a TEKTable that is designed to
hold each diff. UserControl I will ever use?


 
Reply With Quote
 
 
 
 
MSFT
Guest
Posts: n/a
 
      11-10-2003
Hello,

As my understanding, your custom control "TEKTable" is like a DataGrid web
control in ASP.NET. Is this correct? To get a children control in datagrid,
we can use "FindControl" method with the children controls's name. And then
get its type with its GetType method, to determine if it is a Button or
TextBox. To add a eventhandler, we can use AddHandler method. Can these
methods work with your custom control?

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
 
 
 
a
Guest
Posts: n/a
 
      11-10-2003
Here is my code for TEKTable:

Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls

<DefaultProperty("Text"), ToolboxData("<{0}:TekTable
runat=server></{0}:TekTable>")> Public Class TekTable

Inherits Control
Implements INamingContainer


Dim _text As String
Dim intMaxCols As Integer
Dim intMaxWidth As Integer
Dim alUC As New ArrayList

Public Event evtAddToCart()
Public Event Click As EventHandler

<Bindable(True), Category("Appearance"), DefaultValue("")> Property
[Text]() As String
Get
EnsureChildControls()
Return _text
End Get

Set(ByVal Value As String)
EnsureChildControls()
_text = Value
End Set
End Property
<Bindable(True), Category("Appearance"), DefaultValue("3")> Property
myMaxCols() As Integer
Get
EnsureChildControls()
Return intMaxCols
End Get
Set(ByVal Value As Integer)
EnsureChildControls()
intMaxCols = Value
End Set
End Property
<Bindable(True), Category("Appearance"), DefaultValue("800")> Property
myMaxWidth() As Integer
Get
EnsureChildControls()
Return intMaxWidth
End Get
Set(ByVal Value As Integer)
EnsureChildControls()
intMaxWidth = Value
End Set
End Property
<Bindable(True), Category("Appearance"), DefaultValue("")> Property
myUC() As ArrayList
Get
Return alUC
End Get
Set(ByVal Value As ArrayList)
alUC = Value
End Set
End Property


Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
ensurechildcontrols()
Me.RenderChildren(output)
End Sub


Protected Overrides Sub CreateChildControls()
If Me.alUC.Count <> 0 Then

Dim tbl As New Table

Dim r As TableRow
Dim c As TableCell
Dim int As Integer
Dim booAdded As Boolean = False
Dim i As Integer = 1

For int = 0 To alUC.Count - 1
booAdded = False
If i = 1 Then
r = New TableRow
End If

c = New TableCell
c.VerticalAlign = VerticalAlign.Top

Dim uc As ucCookie = alUC.Item(int)

c.Controls.Add(uc)
r.Cells.Add(c)
If i = intMaxCols Then
tbl.Rows.Add(r)
booAdded = True
i = 0
End If
i += 1
tbl.Rows.Add(r)
Next

If booAdded = False Then
tbl.Rows.Add(r)
End If

Me.Controls.Add(tbl)

End If
End Sub
End Class

I have 2 issues: First, I want to perform an action when a Button is
clicked on the ucCookie control. I can't get it to work. Second, I want to
avoid this line:
<<Dim uc As ucCookie = alUC.Item(int)>>
that way I can use the TEKTable control to display any number of columns of
other controls I want.

Does a DataGrid allow me to do this (I don't need TEKTable)?

I can't get the dynamically created UserControl added to a CustomControl to
handle its own events.

Please help.

Kevin

"MSFT" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> As my understanding, your custom control "TEKTable" is like a DataGrid web
> control in ASP.NET. Is this correct? To get a children control in

datagrid,
> we can use "FindControl" method with the children controls's name. And

then
> get its type with its GetType method, to determine if it is a Button or
> TextBox. To add a eventhandler, we can use AddHandler method. Can these
> methods work with your custom control?
>
> Luke
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>



 
Reply With Quote
 
MSFT
Guest
Posts: n/a
 
      11-11-2003
Hi Kevin,

Is "ucCookie" also a custom web control which has a ASP.NET button on it?
If so, you may add the code in the "ucCookie" to handle the click event of
the button. For question 2:

Dim uc As ucCookie = alUC.Item(int)

You may change it to:

Dim uc As Control = alUC.Item(int)

so that is can accept any type of ASP.NET web control.


Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


 
Reply With Quote
 
MSFT
Guest
Posts: n/a
 
      11-13-2003
Hi Kevin,

Is "ucCookie" also a custom web control which has a ASP.NET button on it?

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
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
Internal ASP.Net error bubbling events =?Utf-8?B?RGFsZQ==?= ASP .Net 3 04-14-2006 02:22 AM
ascx / dhtml events bubbling up to ctl event John ASP .Net 1 05-18-2005 09:09 PM
Bubbling up custom events in datagrid Anonymous Poster ASP .Net Datagrid Control 0 01-25-2005 02:02 PM
C# UserControl Bubbling events Andy ASP .Net 3 10-28-2003 04:08 PM
Composite Controls and Bubbling events Javi ASP .Net Building Controls 1 07-09-2003 08:02 PM



Advertisments