Loading user controls programatically into a placeholder (asp.net(vb))

Posted by Phil on Stack Overflow See other posts from Stack Overflow or by Phil
Published on 2010-04-15T09:51:57Z Indexed on 2010/04/15 10:03 UTC
Read the original article Hit count: 387

In my .aspx page I have;

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" AspCompat="True" %>

    <%@ Register src="Modules/Content.ascx" tagname="Content" tagprefix="uc1" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
        <div>
        <asp:PlaceHolder ID="Modulecontainer" runat="server"></asp:PlaceHolder>
        </div>
        </form>
    </body>  
</html>

In my aspx.vb I have;

    Try
        Dim loadmodule As Control
        loadmodule = Me.LoadControl("~/modules/content.ascx")
        Modulecontainer.Controls.Add(loadmodule)
    Catch ex As Exception
        Response.Write(ex.ToString & "<br />")
    End Try

The result is an empty placeholder and no errors.

Thanks a lot for any assistance

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about vb