468,110 Members | 1,583 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,110 developers. It's quick & easy.

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 4386
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Peter | last post: by
1 post views Thread by Jeremy Chapman | last post: by
2 posts views Thread by Peter Rilling | last post: by
1 post views Thread by rn5a | last post: by
4 posts views Thread by =?Utf-8?B?TWFyaw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.