As a web researcher/developer I had the opportunity to get rolling with .Net 3.5 months
before it was released. Because of this I've developed a variety of ASP.NET 3.5 web
applications; this is among one of them which was taken out of a larger context. In this
case, there is no CSS stylesheet or Javascript file. However, in order to demonstrate how
to reference those types of objects, the .Net placeholders remain for them so that you can
see how to reference those types of external files.
Let's Begin
To begin with, you will need to download the following three Microsoft Office Word
2007 docx files. Each file contains complete source code for a specific part of this
project.
Please follow the step by step guide below if master pages under .Net 3.5 is a fairly new
subject to you. Otherwise you may prefer to skip to the next section.
STEP 1
(Enlarge)
Open Visual Studio 2008.
STEP 2
(Enlarge)
Under the File Menu select "New Web Site".
STEP 3
(Enlarge)
1. Under "New Web Site" select ASP.NET Web Site.
2. Specify Location as "File System".
3. Specify Language as "Visual Basic".
4. Type in the network path to the web server, a web site on that web server, and a
folder that the project or "ASP.NET Web Site" will reside at.
STEP 4
(Enlarge)
You will notice that a default web page has been created (Default.aspx).
STEP 5
(Enlarge)
1. Open "Default_aspx.docx" (the source code file mentioned at the top of this web
page) with Microsoft Office Word 2007.
2. Highlight and copy the contents of the page.
3. Highlight the source code section of "Default.aspx".
4. Paste the contents you had copied. This will remove the default code that was
generated with what is contained in the docx file.
STEP 6
(Enlarge)
Under Solution Explorer, expand "Default.aspx". The VB (code-behind) page will
be revealed.
STEP 7
(Enlarge)
1. Right-click on "Default.aspx.vb.
2. From the pop-up menu select "Open".
STEP 8
(Enlarge)
1. Open "Default_aspx_vb.docx" (the source code file mentioned at the top of this web
page) with Microsoft Office Word 2007.
2. Highlight and copy the contents of the page.
STEP 9
(Enlarge)
STEP 10
(Enlarge)
STEP 11
(Enlarge)
Enter the name of the folder as "MasterPages".
STEP 12
(Enlarge)
STEP 13
(Enlarge)
STEP 14
(Enlarge)
STEP 15
(Enlarge)
STEP 16
(Enlarge)
The master page and its code-behind page should now be under the folder named
"MasterPages".
STEP 17
(Enlarge)
STEP 18
(Enlarge)
Congratulations! We are now ready to build what we've put together.
Under the Build menu, select "Build Web Site".
STEP 19
(Enlarge)
The build should succeed and you can now begin experimenting with
Default.aspx by typing in the URL of that web page in your web browser and studying
the output.
Now that a "content placeholder" has been defined in a master page, you will need to
actually define the source code that is associated to the "content placeholder". You do this
by adding a "content" to the ASPX web page which will use the master page in order to
generate the look of the ASPX web page. Inside the "content" you place html code and so
forth which will be rendered in the master page template.
That sounds kind of confusing to me so let's examine some simplified source code. First,
let's look a master page:
<html>
<head id="Head1" runat="server">
<asp:ContentPlaceHolder id="extStylePlaceholder"
runat="server"></asp:ContentPlaceHolder>
</head>
<body>
</body>
</html>
In our master page template you'll see we have defined a "content placeholder". Data will
be inserted into that location when an ASPX page is requested.
In our ASPX page (such as Default.aspx) we have to define a "content" which matches
the "content placeholder" defined in the master page. So, we define the matching
"content" (notice the ID is the same):
<asp:Content ID="Content1" ContentPlaceHolderID="extStylePlaceholder"
runat="server">
<style type="text/css" media="all">@import url("Stylesheet/stylesheetFile.css");</style>
</asp:Content>
Now, when the ASPX page is requested (such as Default.aspx), it will call the master
page in order for it to determine where it should place its "content" blocks. However,
there is one catch!
That is all you need to do in order to work with master pages inside your .Net 3.5 ASPX
web pages.
About Joe
Jenderal Robert adhi
Mucho más que documentos.
Descubra todo lo que Scribd tiene para ofrecer, incluyendo libros y audiolibros de importantes editoriales.
Cancele en cualquier momento.