Solved

Calling ASCX user control randomly

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

19 Experts available now in Live!

Get 1:1 Help Now