User Control doesn't render in VS2005

U

Urs

Hi

the user control below renders OK when added in the designer.
Why does it NOT render when added programmatically? Do I have to instruct
the control somehow to render, or do I miss something?

This is the code when trying to add it ... (during main page Page_Load):

Dim ctl As NewsSnippet = LoadControl(GetType(NewsSnippet),
Nothing)
Me.Controls.Add(ctl)

The user control:

<%@ Control Language="VB" AutoEventWireup="false"
CodeFile="NewsSnippet.ascx.vb"
Inherits="NewsSnippet" %>
<asp:Label ID="lblTitle" runat="server" Font-Bold="True"
Font-Names="Verdana"
Font-Size="10pt"></asp:Label>
<br />
<table style="width: 220px">
<tr>
<td style="width: 75px">
<asp:Image ID="img" runat="server" /></td>
<td style="vertical-align: top">
<asp:Label ID="lblLegend" runat="server" Font-Names="Verdana"
Font-Size="8pt"></asp:Label></td>
</tr>
</table>
<table style="width: 220px">
<tr>
<td style="width: 210px; vertical-align: top;">
<asp:Label ID="lblBody" runat="server" Font-Names="Verdana"
Font-Size="8pt"></asp:Label></td>
</tr>
</table>

Code behind, it's empty as created by VS2005:
Partial Public Class NewsSnippet
Inherits System.Web.UI.UserControl

End Class

Thanks for any hints.
Urs
 
U

Urs

Found the problem and fixed it by using the 1st overload of
LoadControl("NewsSnippet.ascx").

Urs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top