Solved

Calling ASCX user control randomly

Posted on 2014-09-09
2
171 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

679 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