Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / January 2004

Tip: Looking for answers? Try searching our database.

Changing UserControls Dynamically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
William - 30 Jan 2004 04:30 GMT
I have 2 user controls and I would like to display 1 of them depending on a
session variable. I have trie a place holder, but it doesnt seem to work.

ie..
Select Case Session("Variable")
Case "1"
   PlaceHolder1.Controls.Add(New MyControl1)
Case "2"
   PlaceHolder1.Controls.Add(New MyControl2)
End Select

this code does not seem to do anything. How can I acheive this behavior?
Victor Garcia Aprea [MVP] - 30 Jan 2004 04:45 GMT
Hi William,

You need to call the LoadControl method to get an instance of an UserControl
and not the new operator.

Signature

Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup

> I have 2 user controls and I would like to display 1 of them depending on a
> session variable. I have trie a place holder, but it doesnt seem to work.
[quoted text clipped - 8 lines]
>
> this code does not seem to do anything. How can I acheive this behavior?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.