Solved

Calling ASCX user control randomly

Posted on 2014-09-09
2
161 Views
Last Modified: 2014-09-11
Hello, I've a user control I register as follows:

<%@ Register TagPrefix="db" TagName="Banner" Src="~/Banner.ascx" %>

and I call it this way when I need it:

<db:Banner ID="Banner1" runat="server" />


My problem is that the file Im registering (banner.ascx) is not always the same.

Each customer may display a different file, as banner.ascx, or banner2.ascx, etc

The file name is stored on a session variable called banner, so when I try this:

<%@ Register TagPrefix="db" TagName="Banner" Src="~/<%=session("banner")%>" %>

I obviously get an error.

Is there a workaround to assign the name of the user control file randomly?

Thanks.
0
Comment
Question by:SimpleDude
2 Comments
 
LVL 12

Accepted Solution

by:
Jitendra Patil earned 500 total points
ID: 40316766
there is a work around for this problem , you just need to create an object of the user control in the calling page, and in an place holder you can add that control.

for more reference you can check the below links
Dynamic Loading of ASP.NET User Controls
Load ASP.NET User Controls dynamically

hope this helps.
0
 

Author Closing Comment

by:SimpleDude
ID: 40317615
Thanks!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now