473,503 Members | 7,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do u wire up events to controls in a custom template control???

I have a very basic custom control that exposes an ITemplate property and
everything seems pretty straight forward so far.

But, when I put other server controls intro the template section of my
custom control in the ASPX page:

<cc1:MyCustomControl id=MyCustomControl1 runat="server">
<MyTemplate>
<asp:listbox id=ListBox1 runat="server"
AutoPostBack="True"></asp:listbox>
</MyTemplate>
</cc1:MyCustomControl>

.... how am I suppose to programatically access ListBox1 from the ASPX's code
behind?

I realize I can "DOM Craw" my way to it ... but it seems like there must be
a better way. For example, if I double click the ListBox control from the
designer, Visual Studio goes about automatically generating the code to tie
a SelectedIndexChanged event handler to ListBox1. However, the code it
generates fails at runtime because the code behind class doesn't seem to
know anything about an actual instance of ListBox1, even though one
certainly exists way down the Control Tree within MyCustomControl1.

I would like consumers of my control to be able to deal with the controls
they decide to put into the templated sections as if they were putting them
anywhere else in the ASPX document. What do I need to do from here?

TIA from a very tired programmer//

Nov 19 '05 #1
1 1427
Hi Chris
in ur code imports the namespace and than declare this control
protected mycontrol ...................etc
Hope this help :)

"Chris Newby" wrote:
I have a very basic custom control that exposes an ITemplate property and
everything seems pretty straight forward so far.

But, when I put other server controls intro the template section of my
custom control in the ASPX page:

<cc1:MyCustomControl id=MyCustomControl1 runat="server">
<MyTemplate>
<asp:listbox id=ListBox1 runat="server"
AutoPostBack="True"></asp:listbox>
</MyTemplate>
</cc1:MyCustomControl>

.... how am I suppose to programatically access ListBox1 from the ASPX's code
behind?

I realize I can "DOM Craw" my way to it ... but it seems like there must be
a better way. For example, if I double click the ListBox control from the
designer, Visual Studio goes about automatically generating the code to tie
a SelectedIndexChanged event handler to ListBox1. However, the code it
generates fails at runtime because the code behind class doesn't seem to
know anything about an actual instance of ListBox1, even though one
certainly exists way down the Control Tree within MyCustomControl1.

I would like consumers of my control to be able to deal with the controls
they decide to put into the templated sections as if they were putting them
anywhere else in the ASPX document. What do I need to do from here?

TIA from a very tired programmer//

Nov 19 '05 #2

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

Similar topics

1
7536
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
0
1345
by: Mike | last post by:
Hi, I have a class library (dll) in which I defined a class for a custom control (called PlaceHolder). In a separate Web project, I created a custom control (called Template.ascx) that contains...
2
2206
by: Juan Romero | last post by:
Hey guys, I am working on a web custom control that basically draws a table (ASP Table) with a few child controls in the cells. I have a command button inside one of these cells. The problem I...
12
2764
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
15
2150
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
15
6472
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
11
3254
by: Nick Gilbert | last post by:
Hi, How can I create a custom control which will wrap its content in a header and footer? eg: Is it possible to create a .NET user control which can surround other controls? eg:...
4
2673
by: TS | last post by:
Steven, i lost this message conversation from outlook express and made a post online (see last one on this page). Please answer it as it hasn't been yet. thanks The clientID of our controls...
5
4077
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
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...
0
7291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7468
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...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4690
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...
0
3180
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...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.