Hi
I can create webpart-pages using the following code.
(I heard we can use declarative approach to provisioning webpart. But I unable to find the solution how can use declarative approach + C#)
http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/
I can create webpart-pages using the following code.
protected void btnSubmit_Click(object sender, EventArgs e)
{
using (SPWeb oWebsite = SPContext.Current.Web)
{
SPList olist = oWebsite.Lists["Site Pages"];
string xml = GetCreateWebPartPage(olist.ID.ToString(), "SamplePage", 4);
oWebsite.ProcessBatchData(xml);
}
}
private string GetCreateWebPartPage(String list, string pageTitle, int layoutTemplate)
{
const string newItemTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +"<Batch>" +"<Method ID=\"0,NewWebPage\">" +"<SetList Scope=\"Request\">{0}</SetList>" +"<SetVar Name=\"Cmd\">NewWebPage</SetVar>" +"<SetVar Name=\"ID\">New</SetVar>" +"<SetVar Name=\"Type\">WebPartPage</SetVar>" +"<SetVar Name=\"WebPartPageTemplate\">{2}</SetVar>" +"<SetVar Name=\"Overwrite\">true</SetVar>" +"<SetVar Name=\"Title\">{1}</SetVar>" +"</Method>" +"</Batch>";
var newItemXml = string.Format(newItemTemplate, list, pageTitle, layoutTemplate);
return newItemXml;
}
Can anyone tell me using C#,how can I add a webPart (eg.MyCustomWebpart) to the page created from above code ?(I heard we can use declarative approach to provisioning webpart. But I unable to find the solution how can use declarative approach + C#)
http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/
S H A J A N