|
Rank: Member Groups: Member
Joined: 12/17/2007 Posts: 10
|
I want to programatically create a new Tab with its corresponding Page View. But I am getting a really weird behavior with my tests.
Is this possible at all?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Yes. You can do that as if with any other ASP.NET control.
|
|
Rank: Member Groups: Member
Joined: 12/17/2007 Posts: 10
|
This is what I have so far:
Code: HTML/ASPX
<eo:TabStrip ID="TabStrip1" runat="server" ControlSkinID="None" MultiPageID="MultiPage1">
<LookItems>
<eo:TabItem Image-BackgroundRepeat="RepeatX" Image-Mode="TextBackground"
Image-SelectedUrl="00010225" Image-Url="00010222" ItemID="_Default"
LeftIcon-SelectedUrl="00010224" LeftIcon-Url="00010221"
NormalStyle-CssText="color: #606060" RightIcon-SelectedUrl="00010226"
RightIcon-Url="00010223"
SelectedStyle-CssText="color: #2f4761; font-weight: bold;">
<SubGroup OverlapDepth="8"
Style-CssText="font-family: tahoma; font-size: 8pt; background-image: url(00010220); background-repeat: repeat-x; cursor: hand;">
</SubGroup>
</eo:TabItem>
</LookItems>
<TopGroup>
<Items>
<eo:TabItem Text-Html="Themes" PageViewID="PageView1">
</eo:TabItem>
<eo:TabItem Text-Html="Desktop" PageViewID="PageView2">
</eo:TabItem>
</Items>
</TopGroup>
</eo:TabStrip>
<eo:MultiPage ID="MultiPage1" runat="server" Height="180px" Width="100%">
<eo:PageView ID="PageView2" runat="server" Width="100%">
<asp:Button ID="Button1" runat="server" Text="Button" />
</eo:PageView>
<eo:PageView ID="PageView1" runat="server" Width="100%">
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</eo:PageView>
</eo:MultiPage>
<br />
<asp:LinkButton ID="openTabLinkButton" runat="server" Text="Open in new tab." OnClick="openTabLinkButton_Click" />
Code: C#
protected void openTabLinkButton_Click(object sender, EventArgs e)
{
string uidSuffix = Guid.NewGuid().ToString();
Label label = new Label();
label.ID = string.Format("label{0}", uidSuffix);
label.Text = string.Format("Dynamically generated at: {0}", DateTime.Now.ToLongTimeString());
PageView pageView = new PageView();
pageView.ID = string.Format("pageView{0}", uidSuffix);
pageView.Width = new Unit(100, UnitType.Percentage);
pageView.Controls.Add(label);
this.MultiPage1.PageViews.Add(pageView);
TabItem tabItem = new TabItem();
tabItem.Text.Html = DateTime.Now.ToShortTimeString();
tabItem.PageViewID = pageView.ID;
this.TabStrip1.TopGroup.Items.Add(tabItem);
}
I click on my Open in new tab button once and I get a new Tab with its page view. I click again, and I do get a new Tab but the Page Views get all screwed up. I start getting random results when I click on the tabs. Any Ideas?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Please see this post for more details. It's a very common code error: http://www.essentialobjects.com/Forum/Default.aspx?g=posts&t=1056The basic rule here is, while you can change a control's property and ASP.NET will keep the change for you during postbacks, ASP.NET will NOT keep any changes you made to the control tree (add/remove controls, etc) itself. Thanks
|
|
Rank: Member Groups: Member
Joined: 12/17/2007 Posts: 10
|
Got it... New question: do I need to keep track of what I've added? (e.g. ViewState or something like that) or is there a super elegant way to achieve this?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Juan Roman Escamilla wrote:Got it... New question: do I need to keep track of what I've added? (e.g. ViewState or something like that) Please read the other topic posted in the previous post for the answer. Juan Roman Escamilla wrote:is there a super elegant way to achieve this? Unfortunately, as far as I know, none.
|
|