|
-
Apr 13th, 2005, 09:19 AM
#1
Loading a control within a control
I'm very very tired, I might be overlooking something.
On a page named default.aspx, I have placed a control called LeftMenu.ascx.
Now, leftmenu.ascx itself is empty, but in its codebehind, depending upon the a certain Session variable's value, I am trying to load LeftMenuSuper.ascx or LeftMenuHeader.ascx. So, that's a control within a control.
Here is the code in LeftMenu.ascx.vb:
VB Code:
If Session.Item(0).ToString = "normaluser" Then
Me.LoadControl("LeftMenuNormal.ascx")
Else
Me.LoadControl("LeftMenuSuper.ascx")
End If
The problem is, nothing happens. The area where the menu is supposed to be just stays blank, and yes, both of these "child" ascx files contain HTML.
(This is all experimental, so we won't talk about good or bad practices here.)
Help me out, what am I doing or not doing?
-
Apr 13th, 2005, 09:44 AM
#2
Frenzied Member
Re: Loading a control within a control
Correct me if I'm wrong but should it be:
Code:
if (Session.Item[0].ToString() == "normaluser") {
Control normal = LoadControl("LeftMenuNormal.ascx");
Controls.Add(normal);
} else {
Control super = LoadControl("LeftMenuSuper.ascx");
Controls.Add(super);
}
Sorry had to convert to C# cos my VB.NET ain't the best.
If that doesn't work add a placeholder control onto the page and add the Dynamic User control to the placeholder's control collection.
HTH
DJ
If I have been helpful please rate my post. If I haven't tell me!
-
Apr 14th, 2005, 06:02 AM
#3
Re: Loading a control within a control
I finally solved this in the way you've mentioned here, thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|