473,414 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Using inner controls from a tab page control

pnp
I have a tab control and in each tab a custom control. All the custom
controls (different amongst them) have a common function.
What I want to do is when a user clicks on a tab, I want the function of the
control in the tab page to be called. Is there a way to do this without
using a switch statement or an if statement?

Something like this.Tab_Management.SelectedTab.Controls[0] ...
Nov 16 '05 #1
1 1453
Have all of your custom controls implement an interface that contains
the method you want to call when a tab is clicked. You can then loop
through a tab's controls after a click and find the one that implements
your interface.

Something like this (untested) code...

foreach( Control c in targetTab.Controls )
{
if( c is IMyTabControl )
{
IMyTabControl myTabCtl = c as IMyTabControl;
myTabCtl.MyMethod();
}
}

Regards,
-Jeff

pnp wrote:
I have a tab control and in each tab a custom control. All the custom
controls (different amongst them) have a common function.
What I want to do is when a user clicks on a tab, I want the function of the
control in the tab page to be called. Is there a way to do this without
using a switch statement or an if statement?

Something like this.Tab_Management.SelectedTab.Controls[0] ...

Nov 16 '05 #2

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

Similar topics

5
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
1
by: Oleg Ogurok | last post by:
Hi all, In my page class, I'm loading a user control: private void Page_Load(object sender, System.EventArgs e) { Control c = LoadControl("WebUserControl1.ascx"); Controls.AddAt(0, c); }
10
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of...
3
by: msnews.microsoft.com | last post by:
Hello All, I am trying to write Web Controls and in most of the samples I came across, I am seeing the following function where a HTML string is written to create HTML Controls. ///...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
5
by: Nathan Sokalski | last post by:
I am writing a Control that inherits from System.Web.UI.WebControls.CompositeControl. Like many Controls, my Control renders more than just one inner Control. When a postback occurs, I need to get...
0
by: DC | last post by:
Hi, I am dynamically adding a usercontrol that uses "this.IsPostBack" in Page_Load to decide whether it must populate some of it's inner controls or not. Since I am adding the usercontrol to the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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
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
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...

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.