Groups | Blog | Home
all groups > asp.net webcontrols > november 2005 >

asp.net webcontrols : .NET 2 Custom Control question



ME
11/21/2005 10:49:45 AM
I am trying to write my first site using .NET 2. I need a control that will
list several links to pages in a table (a simple nav control). The table
must have about 3 Columns and about 4 rows (or more depending on the amount
of links needed). The table will need to be built dynamically, but it
should display the links in only 1 row or only 1 column. In each cell a
hyperlink will be added (dynamically) that will link a a specific page. The
URL's for the hyperlinks will be read from a Database (used to be able to
use a DataReader, not sure if thats the best way now). In previous .NET 1.1
I could just open a datareader, cycle through and generate the table in the
pre-render event of the custom control. What would be the BEST way of
creating this type of control in .NET 2?

Thanks,

Matt


Table Example:

<table>

<tr>

<td>

<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink></td>

<td>

<asp:HyperLink ID="HyperLink3" runat="server">HyperLink</asp:HyperLink></td>

<td>

<asp:HyperLink ID="HyperLink2" runat="server">HyperLink</asp:HyperLink></td>

</tr>

<tr>

<td >

<asp:HyperLink ID="HyperLink4" runat="server">HyperLink</asp:HyperLink></td>

<td>

<asp:HyperLink ID="HyperLink5" runat="server">HyperLink</asp:HyperLink></td>

<td>

<asp:HyperLink ID="HyperLink6" runat="server">HyperLink</asp:HyperLink></td>

</tr>

<tr>

<td>

<asp:HyperLink ID="HyperLink7" runat="server">HyperLink</asp:HyperLink></td>

<td>

<asp:HyperLink ID="HyperLink8" runat="server">HyperLink</asp:HyperLink></td>

<td>

<asp:HyperLink ID="HyperLink9" runat="server">HyperLink</asp:HyperLink></td>

</tr>

<tr>

<td>

<asp:HyperLink ID="HyperLink10"
runat="server">HyperLink</asp:HyperLink></td>

<td>

<asp:HyperLink ID="HyperLink11"
runat="server">HyperLink</asp:HyperLink></td>

<td>

<asp:HyperLink ID="HyperLink12"
runat="server">HyperLink</asp:HyperLink></td>

</tr>

</table>

Steve C. Orr [MVP, MCSD]
11/21/2005 12:16:50 PM
I can't think of any way that ASP.NET 2.0 makes this kind of custom
requirement much easier.
You could still use your old approach, or you could still use a Repeater, or
you could still use a Table control (that would probably be my preference).

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


[quoted text, click to view]

AddThis Social Bookmark Button