Welcome Guest Search | Active Topics | Sign In | Register

Experiencing on creating TabStrip programmatically Options
Jack.Wu
Posted: Monday, March 21, 2011 10:01:10 AM
Rank: Advanced Member
Groups: Member

Joined: 5/22/2009
Posts: 33
Hello Sir,

I tried to use TabStrip with multiple page view programmatically but can not get the correct way to display the TabStrip control and Multiple PageView.

My test page is:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TabstripCreateTest.aspx.cs" Inherits="TabStrip_TabstripCreateTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>


The code behind is:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EO.Web;

public partial class TabStrip_TabstripCreateTest : System.Web.UI.Page
{
private TabStrip tabStrip;
private MultiPage multiPage;

private EO.Web.TabItem CreateLookItem()
{
EO.Web.TabItem lookItem = new TabItem();

lookItem.LookID = "_Default";
lookItem.LeftIcon.Url = "00010604";
lookItem.LeftIcon.SelectedUrl = "00010605";

lookItem.RightIcon.Url = "00010606";
lookItem.RightIcon.SelectedUrl = "00010607";

lookItem.Height = 21;
lookItem.NormalStyle.CssText = "background-image: url(00010602); background-repeat: repeat-x; font-weight: normal; color: black;";
lookItem.SelectedStyle.CssText = "background-image: url(00010603); background-repeat: repeat-x; font-weight: bold; color: #ff7e00;";

lookItem.SubGroup.ItemSpacing = 1;
lookItem.SubGroup.Style.CssText = "background-image:url(00010601);background-position-y:bottom;background-repeat:repeat-x;color:black;cursor:hand;font-family:Verdana;font-size:12px;";

return lookItem;
}

private void CreateTabstrip()
{
tabStrip = new TabStrip();
this.tabStrip.Visible = true;
this.tabStrip.LookItems.Add(CreateLookItem());
tabStrip.MultiPageID = "mp1";
}

private PageView CreatePageView(int index)
{
string pageViewID;
PageView pageView;

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 = new PageView();
pageViewID = string.Format("pageView{0}", index);
pageView.ID = pageViewID;
pageView.Width = new Unit(100, UnitType.Percentage);
pageView.Controls.Add(label);

return pageView;
}

private TabItem CreateTabItem(string tabName)
{
TabItem tabItem = new TabItem();
tabItem.Text.Html = tabName;

return tabItem;
}

protected void Page_Load(object sender, EventArgs e)
{
int i;
string tabName;
TabItem tabItem;
PageView pageView;
string pageViewID;

if (!IsPostBack)
{
CreateTabstrip();

for (i = 0; i < 2; i++)
{
tabName = string.Format("Tab{0}", i);
pageViewID = string.Format("pageView{0}", i);
tabItem = CreateTabItem(tabName);

tabItem.PageViewID = pageViewID;
tabStrip.TopGroup.Items.Add(tabItem);
}

multiPage = new MultiPage();
multiPage.ID = "mp1";
for (i = 0; i < 2; i++)
{
pageView = CreatePageView(i);
multiPage.Controls.Add(pageView);
}

this.form1.Controls.Add(tabStrip);
this.form1.Controls.Add(multiPage);
//this.CreateChildControls();
}
}
}

Please help to show me the correct way to call a TabStrip programmically. Thank you.
Jack.Wu
Posted: Monday, March 21, 2011 12:58:37 PM
Rank: Advanced Member
Groups: Member

Joined: 5/22/2009
Posts: 33
I got the solution that we can only need to modify the properties of TabStrip.LookItems.Default, the code changed to:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EO.Web;

public partial class TabStrip_TabstripCreateTest : System.Web.UI.Page
{
private TabStrip tabStrip;
private MultiPage multiPage;

private EO.Web.TabItem CreateLookItem()
{
EO.Web.TabItem lookItem = new TabItem();

lookItem.LookID = "_Default";
lookItem.LeftIcon.Url = "00010604";
lookItem.LeftIcon.SelectedUrl = "00010605";

lookItem.RightIcon.Url = "00010606";
lookItem.RightIcon.SelectedUrl = "00010607";

lookItem.Height = 21;
lookItem.NormalStyle.CssText = "background-image: url(00010602); background-repeat: repeat-x; font-weight: normal; color: black;";
lookItem.SelectedStyle.CssText = "background-image: url(00010603); background-repeat: repeat-x; font-weight: bold; color: #ff7e00;";

lookItem.SubGroup.ItemSpacing = 1;
lookItem.SubGroup.Style.CssText = "background-image:url(00010601);background-position-y:bottom;background-repeat:repeat-x;color:black;cursor:hand;font-family:Verdana;font-size:12px;";

return lookItem;
}

private void CreateTabstrip()
{
tabStrip = new TabStrip();
this.tabStrip.Visible = true;
this.tabStrip.LookItems.Add(CreateLookItem());
//TabItem lookItem = this.tabStrip.LookItems.Default;
SetupDefaultTabItem(tabStrip.LookItems.Default);
tabStrip.MultiPageID = "mp1";
}

private void SetupDefaultTabItem(TabItem tabItem)
{
tabItem.LookID = "_Default";
tabItem.LeftIcon.Url = "00010604";
tabItem.LeftIcon.SelectedUrl = "00010605";

tabItem.RightIcon.Url = "00010606";
tabItem.RightIcon.SelectedUrl = "00010607";

tabItem.Height = 21;
tabItem.NormalStyle.CssText = "background-image: url(00010602); background-repeat: repeat-x; font-weight: normal; color: black;";
tabItem.SelectedStyle.CssText = "background-image: url(00010603); background-repeat: repeat-x; font-weight: bold; color: #ff7e00;";

tabItem.SubGroup.ItemSpacing = 1;
tabItem.SubGroup.Style.CssText = "background-image:url(00010601);background-position-y:bottom;background-repeat:repeat-x;color:black;cursor:hand;font-family:Verdana;font-size:12px;";
}

private PageView CreatePageView(int index)
{
string pageViewID;
PageView pageView;

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 = new PageView();
pageViewID = string.Format("pageView{0}", index);
pageView.ID = pageViewID;
pageView.Width = new Unit(100, UnitType.Percentage);
pageView.Controls.Add(label);

return pageView;
}

private TabItem CreateTabItem(string tabName)
{
TabItem tabItem = new TabItem();
tabItem.Text.Html = tabName;

return tabItem;
}

protected void Page_Load(object sender, EventArgs e)
{
int i;
string tabName;
TabItem tabItem;
PageView pageView;
string pageViewID;

if (!IsPostBack)
{
CreateTabstrip();

for (i = 0; i < 2; i++)
{
tabName = string.Format("Tab{0}", i);
pageViewID = string.Format("pageView{0}", i);
tabItem = CreateTabItem(tabName);

tabItem.PageViewID = pageViewID;
tabStrip.TopGroup.Items.Add(tabItem);
}

multiPage = new MultiPage();
multiPage.ID = "mp1";
for (i = 0; i < 2; i++)
{
pageView = CreatePageView(i);
multiPage.Controls.Add(pageView);
}

this.form1.Controls.Add(tabStrip);
this.form1.Controls.Add(multiPage);
//this.CreateChildControls();
}
}
}

It will display a TabStrip with Default style.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.