Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create aspx on the fly? 1

Status
Not open for further replies.

Ecreations

Programmer
Jul 6, 2002
220
0
0
CA
I have an application (Content Management System) in asp which im trying to convert to asp.net using vb.net.
when using asp I created asp pages on the flying using include files and File System Object to save the .aspx pages to the directory. is there anyway to create the aspx pages on the fly other than using FSO to save both .vb and aspx files ?

Thanks in advance
 
My content management engine does exactly that, so yes.

And you never have to create the .vb files. Only the .aspx files are needed to run the app. The <%@ Page %> directive hooks the page to it's parent class, which lives in the compiled assembly (the dll), rather than the .vb (or .cs) files, themselves. Those files never need be published.

In my application, I have a /Templates folder where I store all of my templates. They consist of various UserControls and then a SiteTemplate.template file, which is nothing more than a text file defining how the different UC's relate to each other.

For example, a current implementation of my CMS defines the following SiteTemplate.template file:
Code:
<%@ Page language="c#" %>
<%@ Register TagPrefix="Imagine" TagName="ui_Header" Src="/Imagine/UserControls/Other/Header.ascx" %>
<%@ Register TagPrefix="Imagine" TagName="ui_Footer" Src="/Imagine/UserControls/Other/Footer.ascx" %>
<%@ Register TagPrefix="Imagine" TagName="ui_Menu" Src="/Imagine/UserControls/Other/Menu.ascx" %>
<%@ Register TagPrefix="Imagine" TagName="ui_Body" Src="/Imagine/UserControls/Other/Body.ascx" %>
<HTML>
  <head>
    <title>Imagine</title>
    <meta name="keywords" content="" />
    <link rel=stylesheet type=text/css href="/Imagine/Includes/Imagine.css" />
    <script language=javascript src="/Imagine/Includes/Imagine.js"></script>
  </head>
  <body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
    <form name=theForm id=theForm runat=server>
      <div class=Header>
        <Imagine:ui_Header id=Header runat=Server PageID= />
      </div>
      <div class=Menu>
        <Imagine:ui_Menu id=Menu runat=Server PageID= />
      </div>
      <div class=Body>
        <Imagine:ui_Body id=Body runat=Server PageID= />
      </div>
      <div class=Footer>
        <Imagine:ui_Footer id=Footer runat=Server PageID= />
      </div>
    </form>
  </body>
</HTML>
Note the public property on each UC, PageID, and that they're blank in the template. Upon creation of each page, the database ID is simply plugged in at run time, and then the page is saved off to the /Pages directory as PageName.aspx.

You use a StreamReader to read in the file, do the replace, and then a StreamWriter to write the file. That's sort of like using the FSO, but how else would you do it???

The site is still fully dynamic because I'm free to replace the UC's with whatever I want, and indeed, even change the way that they relate to each other in the .template file if need be. The look and feel is fully defined w/ CSS, with only the top level classes being defined in the .template file, keeping those definitions strictly to the basic layout of the page. But you gain the search engine visibility that is so sorely lacking in many CMS implementations that use QueryString page names.

You can also have those UC's simply again be containers that can dynamically load in other templates, giving your end users the ability to pick from limitless templates that you provide (for a fee, of course ;-))

Hope that helps.

:)
paul

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
Paul
Thank you very much man :)
for the search engine i have managed to rewire the the URL
with the help of a great tutorial by Scott Mitchell Link
when i did rewrite url in asp i had to use a custom 404.asp page as write my pages to the browser.
if anyone wants that asp code i will be more than happy to document it and give it

Once again thanks Paul

Sammy


The solution is simple, the problem is complex.
 
Paul
ecreations how do you use 404 pages to re write the url?
how can the public property used?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top