Hi Marc,
The concept of event bubbling means taking unhandled events and shooting
them up the chain of parent controls until they reach the surface. Event
bubbling does not happen magically, it must be order by the controls when
they fire their events. In the case of built-in ASP.NET controls, not all
events order bubbleing to take place. Button, LinkButton, and ImageButton
are those who do event bubbling. They have an event called Command. A
button's Click event does not automatically bubble up, but its Command
event does:
Protected Overridable Sub OnClick(Byval e as EventArgs)
RaiseEvent Click(Me, e)
End Sub
Protected Overridable Sub OnCommand(Byval e as CommandEventArgs)
RaiseEvent Command(Me, e)
RaiseBubbleEvent(Me, e)
End Sub
The DropDownList does not do event bubbling by default. You will have to
create your own customized DropDownList to bubble event:
Public Class MyDropDownList
Inherits DropDownList
Protected Overrides Sub OnSelectedIndexChanged(ByVal e As
System.EventArgs)
MyBase.OnSelectedIndexChanged(e)
MyBase.RaiseBubbleEvent(Me, New
CommandEventArgs("SelectedIndexChanged", Me))
End Sub
End Class
Using this customized DropDownList in your templates content, then you can
handle the ItemCommand event like this:
Protected Sub t1_ItemCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.CommandEventArgs) Handles t1.ItemCommand
If e.CommandName = "SelectedIndexChanged" Then
Dim ddl As DropDownList = CType(e.CommandArgument, DropDownList)
Response.Write(ddl.SelectedItem.Value)
End If
End Sub
This newsgroup is managed. See
http://msdn.microsoft.com/subscripti...oups/list.aspx for a
complete list of managed newsgroups.
Sincerely,
Walter Wang (, remove 'online.')
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.