Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 615
  • Last Modified:

Calling 1 user control from inside another user control

Hi Experts

I have a Header, Content and Footer split in my Main.aspx page; what I do is call a user control on my page load event:

ContentPane.Controls.Add(Page.LoadControl("~/UC1.ascx"))
ContentPane.Visible = True

Then I want to call a second user control from in side “UC1.ascx” and put it in my HeaderPane.
For example:
HeaderPane.Controls.Add(Page.LoadControl("~/UC2.ascx"))
HeaderPane.Visible = True

How do I get this working?

Thanks for the help
Deon
0
deon001
Asked:
deon001
  • 2
  • 2
1 Solution
 
YZlatCommented:
Dim uc As UserControl
 uc = New UserControl()
uc = Page.FindControl("UC2.ascx")
HeaderPane.Controls.Add(uc)
0
 
deon001Author Commented:
Thanks for the help.

When I use: “HeaderPane.Controls.Add(uc)” I get an error:”HeaderPane is not declared”.

I used: Response.Redirect("Home.aspx?headerpane=LoborControls/uc.ascx")

Thanks
Deon
0
 
YZlatCommented:
how do you declare your HeaderPane?
0
 
deon001Author Commented:
In my Webpage.aspx :

<form id="Main" name="HomePage" method="post" runat="server" class="Body">
<TABLE id="Table1" width="100%" height="100%" cellpadding="0" cellspacing="0" border="3"
                        bordercolor="#296342">
      <TR>
            <TD id="HeaderPane" runat="server" height="60" bgcolor="#296342"></TD>
</TR>
      <TR>
            <TD id="MenuPane" runat="server" height="20"></TD>
      </TR>
      <TR>
            <TD id="ContentPane" runat="server"></TD>
      </TR>
      <TR>
            <TD id="FooterPane" runat="server" height="20"></TD>
      </TR>
</TABLE>
</form>

What I want to do is open a user control say UC2.ascx in the Webpage.aspx’s “HeaderPane” from inside my UC1.ascx.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now