|
Loring Software, Inc |
A Software Developer's Notebook |
|
This is the first time I have used a Master Page on a web application. It is quite simple, and the behavior is
predictable. I have to say it is a long time coming. I wrote a templating
language for HTML in Java right before they released ASP, and it had master
pages. Almost an identical implementation, too. I think I will have
to reformat the Flying Club's web site to use it.
While trying to merge my code into my original web site, written in JScript, I got a strange error. I added a link from this new blog's Nav Bar (on the left) to the index.asp page, and when I ran the debugger I received: Server Error in '/' Application.This type of page is not served.Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.asp' may be incorrect. Please review the URL below and make sure that it is spelled correctly.Requested URL: /index.asp Further investigation into the error shows that you cannot run the Visual Studio web server and navigate to an .asp page. When I tested this on the IIS server normally, it linked as expected. My guess is that there is no way to configure VS to work around this (and a search on the net tends to confirm this).
I needed a list placeholder for the list of blogs on the left hand side. Then I would write a piece of code in the load of the
master page which would iterate over the files in this folder and find all the files with a date as the file name, look at
the header tag inside the file, and create a URL to add to the list.
First stop, the Bulleted List:
<asp
:
BulletedList
runat="server"
ID="BlogList"
DisplayMode="HyperLink"
/> As there are always many ways to skin this cat, I decided to first try the brute force, all in the code behind. In the Page Load code for the master page, I added the following:
ListItem a_newItem =
new ListItem("April 4, 2009 - Developing a .Net Blog",
"20090404.aspx"); So far, so good. I don't really like the bullet, so I look for just a generic list. I want something which I can later bind to, if I ever want to move away from populating the list from the code behind. Let's now try out the Repeater:
<asp:Repeater
runat="server"
ID="BlogListRepeater"> Now, of course, I need a new list to be a data source to the repeater. I like the ListItems object, so lets stick with that.
ArrayList a_array =
new ArrayList(); Last thing to do is Figure out the real list of items from a directory listing:
protected void
Page_Load(object sender,
EventArgs e) The rest is the job of the eye candy specialists... Lacking that, perhaps I will mess with the colors a bit. One thing I could actually do would be to save the array of blog entries into a Context. But file operations are so fast these days, I wouldn't bother considering it (unless of course this blog starts to get a million hits a day!) |
|
|
Copyright © 2010 Loring Software, Inc. All Rights Reserved Questions about what I am writing about? Email me |
|