I am kinda new to .NET. I've been searching the Internet for a good VB example showing how to create a tabstrip/multipage control dynamically. I've found plenty of examples showing how to modify an already existing tabstrip/multipage, but nothing showing how
to create one in VB. Any examples would be great. Also, I plan to nest multiple tabstrip/multipage controls inside one another, so any suggestions for doing that would also be helpful. Thanks in advance!
I did look at that example. Unfortunately, it is written in c#, not VB. I can gain some insight from looking at it, but would really like to see a VB example. I've got to believe that someone has done this in VB before.
You can try these C# to VB online translators: -> http://authors.aspalliance.com/aldotnet/examples/translate.aspx -> http://www.kamalpatel.net/ConvertCSharp2VB.aspx
Thanks for the information Bill! In the meantime, I have come up with some code of my own. It is still a work in progress, but here is what I have so far:
<script runat="server">
Private Sub Page_Load(ByVal Sender as System.Object, ByVal e as System.EventArgs)
Dim tsMain As New TabStrip
Dim mpMain As New Multipage
tsMain.ID = "tsMain"
mpMain.ID = "mpMain"
tsMain.TargetID = mpMain.ID
'TabStrip Size
tsMain.width = Unit.Pixel(540)
tsMain.height = Unit.Pixel(30)
Call applyTabStripStyle(tsMain)
'MultiPage Size
mpMain.width = tsMain.width
mpMain.height = Unit.Pixel(400)
Call applyMultiPageStyle(mpMain)
Call addTab("1", tsMain, mpMain, False) 'name, tabstrip, multipage, addSubStrip?
Call addTab("2", tsMain, mpMain, True)
Call addTab("3", tsMain, mpMain, False)
Call addTab("4", tsMain, mpMain, False)
Call addTab("5", tsMain, mpMain, True)
Page.Controls.Add(tsMain)
Page.Controls.Add(mpMain)
End Sub
Private Sub addTab(name As String, ts as TabStrip, mp As MultiPage, addSub As Boolean)
Dim t As New Tab
Dim p As New Pageview
Dim l As New Label
t.Text = "Tab " & name
l.Text = "Page " & name
p.ID = "Pg"& name
p.Controls.Add(l)
ts.Items.Add(t)
mp.Controls.Add(p)
If addSub Then
l.Text = ""
Call addSubStrip(p.ID & "Sub", p)
End If
End Sub
Private Sub addSubStrip(name As String, pv As Pageview)
Dim ts As New Tabstrip
Dim mp As New MultiPage
ts.ID = "ts" & name
mp.ID = "mp" & name
ts.TargetID = mp.ID
pv.Controls.Add(ts)
pv.Controls.Add(mp)
'TabStrip Size
ts.width = Unit.Pixel(420)
ts.height = Unit.Pixel(25)
Call applyTabStripStyle(ts)
'MultiPage Size
mp.width = ts.width
mp.height = Unit.Pixel(190)
Call applyMultiPageStyle(mp)
Call addTab(name & "1", ts, mp, False)
Call addTab(name & "2", ts, mp, False)
Call addTab(name & "3", ts, mp, False)
End Sub
Private Sub applyTabStripStyle(ts As TabStrip)
ts.TabDefaultStyle.Add("background-color", "#336699")
ts.TabDefaultStyle.Add("color", "blue")
End Sub
Private Sub applyMultiPageStyle(mp As MultiPage)
mp.borderWidth = Unit.Pixel(2)
End Sub
</script>
<form runat="server">
</form>
I plan to eventually make the number of tabs/subtabs completely dynamic by pulling the information
from a MySQL database and I also plan to pull a set of styles (skins or themes) from the database also. Any comments or suggestions would be welcome. Thanks ~Steve~
here is some example C# snippits that will hopefully layout the major steps. Note that you can either build the content on each page view using the Table, Row, Cell object model, or you can override each page view's render method. The latter approach is a bit
more efficient in terms of ViewState and the size of the internal control tree. using Microsoft.Web.UI.WebControls; ... protected TabStrip TabStrip1 = new TabStrip(); protected Tab Tab1 = new Tab(); protected Tab Tab2 = new Tab(); protected MultiPage MultiPage1
= new MultiPage(); protected PageView Page1 = new PageView(); protected PageView Page2 = new PageView(); ... protected TextBox1 txtControl1 = new TextBox(); protected TextBox2 txtControl2 = new TextBox(); Page1.Controls.Add(TextBox1); // add controls to page
view Page2.Controls.Add(TextBox2); MultiPage1.ID = "MultiPage1"; // multipage must have an ID MultiPage1.Controls.Add(Page1); // add page views to multipage MultiPage2.Controls.Add(Page2); Tab1.Text = "Fist Tab"; // configure the tabs Tab2.Text = "Second Tab";
TabStrip1.Items.Add(Tab1); // add tab to tabstrip TabStrip1.Items.Add(Tab2); this.Controls.Add(this.TabStrip); // add tab strip to page or control this.TabStrip.TargetID = this.MultiPage.ID; // set the tab's target this.Controls.Add(this.MultiPage); // add
the multipage to page or control
Hi all, I tried the code sample above, but I didn't create the Tabstrip and The MultiPage dynamically they already exist within the page. I created the pageView and the tabs in the Page Load and when I start the page my Tabs appear above the tabcontrol. Any
ideia to solve this? Thanks in a dvance, Agus
stevei00
Member
35 Points
7 Posts
Dynamically create Tabstrip/Multipage?
Sep 20, 2004 01:30 PM|LINK
Bill2clone
Star
9975 Points
1995 Posts
Re: Dynamically create Tabstrip/Multipage?
Sep 20, 2004 01:57 PM|LINK
Tressleworks modules
DNN & webhosting
IEWCtrls
stevei00
Member
35 Points
7 Posts
Re: Dynamically create Tabstrip/Multipage?
Sep 20, 2004 02:33 PM|LINK
Bill2clone
Star
9975 Points
1995 Posts
Re: Dynamically create Tabstrip/Multipage?
Sep 21, 2004 11:04 AM|LINK
Tressleworks modules
DNN & webhosting
IEWCtrls
stevei00
Member
35 Points
7 Posts
Re: Dynamically create Tabstrip/Multipage?
Sep 21, 2004 02:54 PM|LINK
<script runat="server"> Private Sub Page_Load(ByVal Sender as System.Object, ByVal e as System.EventArgs) Dim tsMain As New TabStrip Dim mpMain As New Multipage tsMain.ID = "tsMain" mpMain.ID = "mpMain" tsMain.TargetID = mpMain.ID 'TabStrip Size tsMain.width = Unit.Pixel(540) tsMain.height = Unit.Pixel(30) Call applyTabStripStyle(tsMain) 'MultiPage Size mpMain.width = tsMain.width mpMain.height = Unit.Pixel(400) Call applyMultiPageStyle(mpMain) Call addTab("1", tsMain, mpMain, False) 'name, tabstrip, multipage, addSubStrip? Call addTab("2", tsMain, mpMain, True) Call addTab("3", tsMain, mpMain, False) Call addTab("4", tsMain, mpMain, False) Call addTab("5", tsMain, mpMain, True) Page.Controls.Add(tsMain) Page.Controls.Add(mpMain) End Sub Private Sub addTab(name As String, ts as TabStrip, mp As MultiPage, addSub As Boolean) Dim t As New Tab Dim p As New Pageview Dim l As New Label t.Text = "Tab " & name l.Text = "Page " & name p.ID = "Pg"& name p.Controls.Add(l) ts.Items.Add(t) mp.Controls.Add(p) If addSub Then l.Text = "" Call addSubStrip(p.ID & "Sub", p) End If End Sub Private Sub addSubStrip(name As String, pv As Pageview) Dim ts As New Tabstrip Dim mp As New MultiPage ts.ID = "ts" & name mp.ID = "mp" & name ts.TargetID = mp.ID pv.Controls.Add(ts) pv.Controls.Add(mp) 'TabStrip Size ts.width = Unit.Pixel(420) ts.height = Unit.Pixel(25) Call applyTabStripStyle(ts) 'MultiPage Size mp.width = ts.width mp.height = Unit.Pixel(190) Call applyMultiPageStyle(mp) Call addTab(name & "1", ts, mp, False) Call addTab(name & "2", ts, mp, False) Call addTab(name & "3", ts, mp, False) End Sub Private Sub applyTabStripStyle(ts As TabStrip) ts.TabDefaultStyle.Add("background-color", "#336699") ts.TabDefaultStyle.Add("color", "blue") End Sub Private Sub applyMultiPageStyle(mp As MultiPage) mp.borderWidth = Unit.Pixel(2) End Sub </script> <form runat="server"> </form>I plan to eventually make the number of tabs/subtabs completely dynamic by pulling the information from a MySQL database and I also plan to pull a set of styles (skins or themes) from the database also. Any comments or suggestions would be welcome. Thanks ~Steve~CometCoder
Member
35 Points
7 Posts
Re: Dynamically create Tabstrip/Multipage?
Oct 06, 2004 05:11 AM|LINK
agus_ayala
Member
35 Points
7 Posts
Re: Dynamically create Tabstrip/Multipage?
Oct 20, 2004 06:55 PM|LINK