How to include a webpage?

B

brett

I need to include some webpages and am doing this in my index page:

<%@ Register TagPrefix="mysite" TagName="section1"
Src="/sub/section1.ascx" %>
<%@ Register TagPrefix="mysite" TagName="section2"
Src="/sub/section2.ascx" %>
<%@ Register TagPrefix="mysite" TagName="section3"
Src="/sub/section3.ascx" %>

On my main page, I'd like to include pages via URL. For example:

index.aspx?p=section1
index.aspx?p=section2
index.aspx?p=section3

I use this to bring in the selected page.

<p><mysite:%p%runat="server" /></p>

but how do I have it dynamically use the "p" variable? Of course the
above doesn't work.

Also, how do I set a default "p" value.

Thanks,
Brett
 
P

Peter Rilling

By the time any code actually runs, ASP.NET has already created the object
model.

How about using a placeholder and using LoadControl in the code to load the
controls dynamically?
 
B

brett

Thanks. That's what I'm doing now.

I'm having another problem related to file names for the user controls.
If I have
index.ascx
sub/index.ascx

I'll get an error that index_aspx is defined in multiple places. If I
rename sub/index.ascx to sub/indexsub.ascx, all is fine. Both ASCX
files have different class names. Am I doing something wrong that it
won't let me have the same file name in different folders?

Thanks,
Brett
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top