PC Review


Reply
Thread Tools Rate Thread

Custom webcontrol

 
 
Veerle
Guest
Posts: n/a
 
      24th May 2007
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(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public List<Tab> Tabs
{
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;
}
}
}

 
Reply With Quote
 
 
 
 
Veerle
Guest
Posts: n/a
 
      24th May 2007
On 24 mei, 09:52, Veerle <veerleve...@hotmail.com> wrote:

> 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!


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Event on Custom WebControl Alhambra Eidos Kiquenet Microsoft ASP .NET 1 27th Nov 2007 02:42 PM
Custom WebControl with OnClick event Tomasz J Microsoft ASP .NET 3 3rd Oct 2007 03:32 PM
Custom WebControl Ernest Morariu Microsoft ASP .NET 0 7th Mar 2006 03:29 PM
Custom WebControl using DataBoundControl and Templates =?Utf-8?B?SmFmZmE=?= Microsoft ASP .NET 0 7th Dec 2005 05:41 PM
Custom Calendar webcontrol Peter Microsoft ASP .NET 1 3rd Nov 2005 10:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 AM.