开发者

How to add webpartzone in sharepoint 2010 programmatically on C#?

I have a really simple question and probably hard answer. How to add webpartzone into my sharepoint page using C# code? What I did is: I create visual web part project and added this code to page_init event of it:

protected void Page_Init(object sender, EventArgs e)
{
    WebPartZone webPartZone1 = new WebPartZone();
    webPartZone1.AllowLayoutChange = true;
    webPartZone1.EmptyZoneText = "No Data are provided";
    webPartZone1.Enabled = true;
    webPartZone1.HeaderText = "My Custom Zone";
    webPartZone开发者_StackOverflow中文版1.Visible = true;

    this.Page.Controls.Add(webPartZone1);
} 

and it's doesn't work. but can give you some idea of what I want. I'm really confused.


I think, what you're trying is a bit wrong, you're trying to add a web part zone in a web part. I don't know if it is possible but you can try to create it via code to a master page.

I mean, you will not add the created web part zone control in "this.page" but to its master.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜