473,662 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create WebPartZones Programmaticall y

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(EventArg s 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.A dd(zone);
row.Cells.Add(c ell);
}
_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(HtmlText Writer writer)
{
_t.RenderContro l(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 1146

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

Similar topics

1
422
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
13625
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 for a VS.NET setup project. Zip files will not do because these shall be distributed via System Management Server (SMS).
3
6993
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 have a Table, in exactly the same Field format, in each of these 'Weekly' DataBases. I want to set-up a new 'Master' Database, so that I can write one Query to search all the 'Weekly' Databases and produce one new Table in the 'Master' Database...
5
5602
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 that these files will need to be created programmatically. I think saving the DataSets into Access .mdb files is a logical choice, but I'm unable to find any information for creating NEW databases programmatically and I can only find information...
3
3706
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 the same? Does it really matter? I have created databases with .NET programmatically and it works fine, but why would anyone want to do all this typing when they can easily point and click inside the program? It took a few hours of typing for...
14
6109
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 places in that hosting.
0
1024
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 down as the footer. How can we constrain the movement of webparts so that the user cannot drag the left nav and place in the location of the header? What webpartzones will have to be created?
0
1460
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 to finish. thanks
11
2938
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, having hyperlinks to the corresponding full size images. Can anybody point me to locations in MSDN or elsewhere giving the references to attach, the commands & objects for creating or opening the pages and possibly available classes? I have done...
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8768
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7368
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.