I followed this tutorial to make a tabzone webpart. if I want to manually add it to a page it works perfectly, but if I try to add it programmatically, it gives me out of index exception, which is because i need to set its XML property.
Here is my Code for adding a webpart
using (SPSite mySite = new SPSite(PageUrl))
{
using (SPWeb web = mySite.OpenWeb())
{
AddTabbedWebpart(web);
}
}
public void AddTabbedWebpart(SPWeb web)
{
SPLimitedWebPartManager wpManger = web.GetLimitedWebPartManager("default.aspx", PersonalizationScope.Shared);
TabbedWebPartZoneTabs webpart = new TabbedWebPartZoneTabs();
webpart.Title = "Survey Tabs";
webpart.AllowClose = true;
webpart.AllowMinimize = true;
webpart.AllowConnect = true;
webpart.ChromeType = PartChromeType.None;
webpart.ChromeState = PartChromeState.Normal;
webpart.AllowZoneChange = true;
webpart.AllowHide = true;
webpart.ExportMode = WebPartExportMode.All;
webpart.Hidden = false;
webpart.AllowEdit = true;
//webpart.ZoneTabXml = ??
wpManger.AddWebPart(webpart, "Top", 1);
wpManger.Dispose();
}
When i exported the webpart, i came to know that ZoneTabXML actually contains xml code something like this,
ZoneTabXml"
type="string"><tabs><
tab name="A"><
webPart title="2010 Last Day"
visible="false" /><webPart title="Dates"
visible="false" /><webPart title="Events"
visible="false" /><webPart title="asdasdasd"
visible="false" /><webPart title="asdasd asdasd"
visible="false" /><webPart title="asdasdasdas dd"
visible="false" /><webPart title="Ssdasdasd List"
visible="false" /></tab><tab name="Surdfgveys"><
webPart title="Tasdsd asds"
visible="false" /><
webPart title="iiiiiiiiis"
visible="false" /><webPart title="ddddddfon"
visible="false" /><webPart title="Tdfdf fordfds"
visible="false" /><webPart title="Tdfdf dfes"
visible="false" /><webPart title="Tdfgerger es"
visible="false" /></tab><tab name="dfgfgdfd gs">< carries on...
Now i got no clue how to setup this as property of webpart, as far as i know by the webpart is using HTML code to dynamically create a custom XML property of webpart. Do I have to create a instance of a editor class or something ?
well confused and stuck !