473,405 Members | 2,171 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,405 software developers and data experts.

Custom webcontrol

Hi,

I use the infragistics tabcontrol on several pages of my application,
that looks like this:

<igtab:UltraWebTab ID="MyTabPage" runat="server">
<Tabs>
<igtab:Tab Key="Tab1" Text="Title for tab 1">
<ContentTemplate>
Content of tab 1, can contain usercontrols or
webcontrols
</ContentTemplate>
</igtab:Tab>
<igtab:Tab Key="Tab2" Text="Title for tab 2">
<ContentTemplate>
Content of tab 2, can contain usercontrols or
webcontrols
</ContentTemplate>
</igtab:Tab>
</Tabs>
</igtab:UltraWebTab>
</ao:Panel>

I tried creating my own tabcontrol, internally using the infragistics
tabcontrol to do it. The markup now looks like:

<ao:TabView runat="server" ID="MyTabPage">
<ao:Tab runat="server" ID="Tab1" Title="Title for tab 1">
Content of tab 1, can contain usercontrols or webcontrols
</ao:Tab>
<ao:Tab runat="server" ID="Tab2" Title="Title for tab 2">
Content of tab 2, can contain usercontrols or webcontrols
</ao:Tab>
</ao:TabView>

On the first tab, there are some controls in the markup that are set
to Invisible = true in the code behind of the page (on prerender).
Also, the second tab is set to Invisible = false in the code behind of
the page (on prerender).

There is also a button on the page, and when clicked, the second tab
is changed to Visible = true, in other words: there is a postback that
changes the second tab from invisible to visible.
For the infragistics tabcontrol, this is done by:
MyTabPage.Tabs[1].Visible = false;
For my custom tabcontrol, this is done with the same syntax:
MyTabPage.Tabs[1].Visible = false;

Now the problem: when using the infragistics tabcontrol and switching
the second tab from invisible to visible, the invisible controls on
the first tab stay invisible. In my custom tabcontrol, the invisible
controls on the first tab become visible as well, and of course I
don't want that. I'm probably making a beginners mistake (because I am
a beginner), but I have no clue what the source of the problem is...

Here is my code:

[DefaultProperty("Tabs"),
ParseChildren(true, "Tabs")]
public class TabView : CompositeControl, INamingContainer
{
private List<Tab_tabs;
private UltraWebTab _ultraWebTab;

protected override void CreateChildControls()
{
Controls.Clear();

_ultraWebTab = new UltraWebTab();
foreach(Tab tab in Tabs)
{
Infragistics.WebUI.UltraWebTab.Tab tabItem = new
Infragistics.WebUI.UltraWebTab.Tab(tab.Title);
tabItem.Key = tab.ID;
tabItem.ContentPane.Controls.Add(tab);
_ultraWebTab.Tabs.Add(tabItem);
}
this.Controls.Add(_ultraWebTab);
ChildControlsCreated = true;

ClearChildViewState();
}
[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
PersistenceMode(PersistenceMode.InnerDefaultProper ty)]
public List<TabTabs
{
get
{
if (_tabs == null)
_tabs = new List<Tab>();
return _tabs;
}
}

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
EnsureChildControls();
foreach (Infragistics.WebUI.UltraWebTab.Tab tabItem in
_ultraWebTab.Tabs)
{
if (tabItem.ContentPane.Controls.Count == 1)
{
Tab tab = tabItem.ContentPane.Controls[0] as Tab;
if (tab != null)
tabItem.Visible = tab.Visible;
}
}
}
}

public class Tab : Panel, INamingContainer
{
public string Title
{
get
{
return (string)ViewState["TabTitle"] ?? "";
}
set
{
ViewState["TabTitle"] = value;
}
}

public override bool Visible
{
get
{
return (bool?)ViewState["VisibleTab"] ?? true;
}
set
{
ViewState["VisibleTab"] = value;
}
}
}

May 24 '07 #1
1 4593
On 24 mei, 09:52, Veerle <veerleve...@hotmail.comwrote:
On the first tab, there are some controls in the markup that are set
to Invisible = true in the code behind of the page (on prerender).
Also, the second tab is set to Invisible = false in the code behind of
the page (on prerender).
I forgot to mention something important:
I only set the controls on the first tab to Invisible = true in the
prerender when it's not a postback. When I also set it when it is a
postback, then the problem is solved. But when using the Infragistics
control, it does work when only setting the Invisible when it's not a
postback, so I would really like to get that to work in my custom
tabcontrol as well!
May 24 '07 #2

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

Similar topics

19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
1
by: Divya | last post by:
Hello This is my 1st project where I have to create a Webcontrol. I have created a simple custom control with a button and 2 labels added to a panel. My problem is that the event handler that I...
2
by: Novice | last post by:
I can't seem to get my Custom WebControl to output a button whose click event is associated with a particular method. Here is the code I have right now that contains a panel and there is a...
0
by: Novice | last post by:
Hey all, I've already posted this question and two posters offered suggestions and they worked - but now I would like to know why - and if possible the answer to a second question. Here is my...
1
by: Novice | last post by:
Hey all, I have finally managed to create a Custom WebControl and am using a technique from another programmer to maintain state between pages - I would just like to validate this idea. ...
1
by: Peter | last post by:
I have a dilemna. Currently I have created a custom calendar webcontrol that a user can select and will dump the date along with some specialized information set in the tooltip. It actually is...
1
by: Jeremy Chapman | last post by:
I have a property will an array of webcontrols. The control features a custom property editor which can add and remove web controls to the array, but how do I persist the informtion by...
2
by: Peter Rilling | last post by:
Okay, I something weird is happening where I do not know if I am doing something wrong. I have a page that contains a custom webcontrol that I developed. This webcontrol basically loads a...
1
by: rn5a | last post by:
While creating a custom control, what is the difference between Public Class MyCls : Inherits Control & Public Class MyCls : Inherits WebControl Also when should the sub Render be used &...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi, I have built a custom control button which inherits from WebControl and implements IPostBackEventHandler. The control also declares an event Click and provides a method OnClick which invokes...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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.