473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Create WebPartZones Programmatically

Hi,

I'm trying to create a custom control in ASP.NET 2.0 that will create a
table with a user definable number of rows and columns with a
WebPartZone in each cell.

Here's the code I have at present:

public class ZoneTable : Control
{
private int _cRows;
private int _cColumns;
Table _t;

public ZoneTable()
{
_t = new Table();
}

public int Rows
{
get { return _cRows; }
set { _cRows = value; }
}

public int Columns
{
get { return _cColumns; }
set { _cColumns = value; }
}

protected override void OnInit(EventArgs e)
{
_t.ID = "MyTable" + ID;
_t.BorderWidth = 1;

for (int ixRow = 0; ixRow < Rows; ++ixRow)
{
TableRow row = new TableRow();
for (int ixCol = 0; ixCol < Columns; ++ixCol)
{
WebPartZone zone = new WebPartZone();
zone.ID = GetZoneID(ixRow, ixCol);

TableCell cell = new TableCell();
cell.ID = "cell" + zone.ID;
cell.Controls.Add(zone);
row.Cells.Add(cell);
}
_t.Rows.Add(row);
}

base.OnInit(e);
}

private string GetZoneID(int ixRow, int ixCol)
{
return string.Format("{0}_R{1}C{2}", ID, ixRow, ixCol);
}

protected override void Render(HtmlTextWriter writer)
{
_t.RenderControl(writer);
}
}

I read that WebPartZones need to be created on or before Page_Init in
the page life cycle so that's why I'm creating the table elements in
the OnInit method.

The table cells are rendered to HTML, but the WebPartZones are not. For
some reason, if I add the WebPartZones to the form instead of the
individual cells in the table, they are rendered at the bottom of the
page, but not inside the table cells were I need them!

Any help much appreciated,
Todd

Jun 13 '06 #1
0 1133

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Silvia | last post by:
My question is that is posible create a IIS Virtual Directory programmatically with visual Basic.NET?? Is posible create a Application Pool programmatically too? Thanks
4
by: Thomas Jespersen | last post by:
Hello I want to create a MSI file programmatically. Do you know of any third party .NET component which can help me with that? I'm going to use it like a self extracting zip. So it is not...
3
by: G rumpy O ld D uffer | last post by:
This is probably a 'Low-Level' question to all the ACCESS experts but I've only been using ACCESS for a couple of weeks. I've been given 30+ (and counting) separate 'Weekly' Databases which all...
5
by: Jacob | last post by:
Happy New Year! I'm writing a program that will need to store large amounts of data from several DataSets that I create at runtime (for information like email, calendar, etc...). The trick is...
3
by: R Reyes | last post by:
Just wondering if anyone knows the pros/cons between creating a database programmatically vs using the application's tool windows/features that come with SQLServer, Access, Oracle, etc... Is it...
14
by: mistral | last post by:
Need php script to create mySQL database programmatically; since hosting configuration may not allow create database from script, script also need eliminate/rewrite all restrictions in appropriate...
0
by: yashgt | last post by:
We have a ASP .NET 2.0 app that has a header, left nav and center. We want to provide a design mode so that the left nav and center can be interchanged. Also the header can be dragged and brought...
0
by: =?Utf-8?B?YmFycnk=?= | last post by:
After the user has moved a webpart from within the display mode can you then programmatically put the mode back to browse without the user having to do this but at the same time allowing the move...
11
by: =?Utf-8?B?UGV0ZXIgSw==?= | last post by:
I am working with Visual Studio or alternately with Expression Web. I need to create about 50 aspx pages with about 1200 thumbnali images, typically arranged in three to four groups per page,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.