谁知道怎样在asp.net的webform里用C#添加类似于winform里的tabcontrol控件啊
谁知道怎样在asp.net的webform里用C#添加类似于winform里的tabcontrol控件啊
我希望的是用asp.net实现,而不是用纯js脚本来实现,
有人说用Menu控件 + MultiView控件来实现,静态的很好弄,也成功了,但是如果弄成动态的呢?
前台代码:
C# code
<asp:Menu ID="menuTabs" CssClass="menuTabs" StaticMenuItemStyle-CssClass="tab" StaticSelectedStyle-CssClass="selectedTab"
Orientation="Horizontal" OnMenuItemClick="menuTabs_MenuItemClick" runat="server">
<Items>
<asp:MenuItem Text="Tab 1" Value="0" Selected="true" />
<asp:MenuItem Text="Tab 2" Value="1" />
<asp:MenuItem Text="Tab 3" Value="2" />
</Items>
</asp:Menu>
<div class="tabBody">
<asp:MultiView ID="multiTabs" ActiveViewIndex="0" runat="server">
<asp:View ID="view1" runat="server">
<asp:CheckBox ID="CheckBox1" runat="server" />
Contents of first tab </asp:View>
<asp:View ID="view2" runat="server">Contents of second tab </asp:View>
<asp:View ID="view3" runat="server">Contents of third tab </asp:View>
</asp:MultiView>
后台代码:
C# code
protected void menuTabs_MenuItemClick(object sender, MenuEventArgs e)
{
multiTabs.ActiveViewIndex = Int32.Parse(menuTabs.SelectedValue);
}
我就想弄个动态滴,哪位大侠做过,或者弄帮我优化成动态的,就谢谢了!!
------解决方案--------------------
可使用TabPanel实现
<script type="text/javascript" >
var tabpanela;
var toolbara;
$(document).ready(function() {
tabpanela = new TabPanela({
renderTo: 'tab',
border: 'none',
active: <%=activeId %>,
maxLength: 10,
items: [ {
id: 'toolbaraPlugin2',
title: 'a',
html: '<iframe id="callIframe" src="Query1.aspx?type=2" width="100%" height="100%" frameborder="0"></iframe>',
closable: false
}, {
id: 'toolbaraPlugin3',
title: 'b',
html: '<iframe id="callIframe" src="Query1.aspx?type=3" width="100%" height="100%" frameborder="0"></iframe>',
closable: false
}
]
});
});
var i = 0;
function addadd() {
TabPanela.addTab({ title: 'Tab ' + (++i), html: '<iframe src="" width="100%" height="100%" frameborder="0"></iframe>' })
}
</script>
------解决方案--------------------
http://code.google.com/p/springside-common/source/browse/springside-common/webapp/js/tabs/TabPanel.js?spec=svn50&r=50