"Dynamic" include files?

B

Buddy Robbins

Hey folks,
I am re-writing an ASP.Net site for a company.
The client wants to be responsible for the static content and navigation of
their site, and I'll be responsible for any dynamic content.

I'm using Infragistics Ultra Web Navigator, which can load the menus from an
XML file, so the navigation requirement is taken care of.

I had created a generic aspx file that accepts the static content filename
as a query string. The ASPX form has a header user web control (containg
the menu control) and a footer user web control.
Between the two, I'm using a select statement based on the query string to
process the appropriate include file statements for the "guts" of the static
content.

This works fine right now, however, if the client wants to add new static
pages, the default.aspx file has to be edited to add the case for the new
web page.

This seems like a clunky way to do it, and I can't figure out how go
generate the include file line dynamically.

Could anyone point me in a direction that will accomplish this?


Thanks in advance,
-Buddy Robbins
 
B

Ben Miller [MSFT]

You will want to use the User Control way (ASCX). As you can take and use
the Page.LoadControl(stringFromQueryString + ".ascx") and add this control
to a placeholder.

<asp:placeHolder id="place" runat="server" />

In code...

Sub Page_Load()

Dim somevar as string
If Request.QueryString("querystringvarname") Is Nothing Then
somevar = "somecontrolThatShowsError"
Else
somevar = Request.Querystring("querystringvarname")
End If

place.Controls.Add(Page.LoadControl(somevar & ".ascx"))

End Sub

HTH.
Ben Miller
This post is provided "AS IS" and the code samples express no liabilities or
warranties of any kind.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top