Solved

Creating an inc file in Dreamweaver

Posted on 2009-07-13
7
443 Views
Last Modified: 2012-05-07
I'm trying to follow the tutorial on this  here: http://www.w3schools.com/asp/asp_incfiles.asp. My testing server is a remote Windows server.

So how do I create the .inc file? I tried just saving their Time.inc code as an inc file, but of course it doesn't work. Another option, according to the tutorial is to use asp files instead. Which would be fine except that I don't know what the full context is for their code in theTime.inc file.

Just to get my learning process going, what would the ENTIRE code be for the asp version of their time.inc code.

I know I'm all over the place here but I learn best when I see a complete example of a process right on my own computer

Thanks,
John

Here is the "time.inc" file:
 

<%

Response.Write(Time)

%>
 

What is everything that comes before and after this code?

Open in new window

0
Comment
Question by:gabrielPennyback
  • 4
  • 3
7 Comments
 
LVL 19

Expert Comment

by:daveamour
Comment Utility
That looks fine
You include this in another page - eg Default.asp as follows
<!--#include virtual="/time.inc" -->
0
 
LVL 1

Author Comment

by:gabrielPennyback
Comment Utility
Hi daveamour, thanks for posting but I still can't get it to work. Could you take a look at the codes for the two docs I have and let me know where I'm going wrong. Please re-post both codes with the proper corrections, otherwise I won't know exactly where in the code to place your changes.

When I preview "TimeInclude.aspx" I get this error:
Compiler Error Message: CS0103: The name 'Time' does not exist in the current context
which refers to the line: Line 10: Response.Write(Time) in "Time.aspx"

Thanks,

John


TIMEINCLUDE.ASPX
 

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

<body>

Blah, Blah .....

<p></p>

More blah, blah ...

<p></p>

<!--#include virtual="time.inc" --> 
 

</body>

</html>
 

TIME.ASPX

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

<body>

<%

Response.Write(Time)

%>
 

</body>

</html>

Open in new window

0
 
LVL 19

Accepted Solution

by:
daveamour earned 500 total points
Comment Utility
I see what's happening.
The tutorial you were reading is for Classic ASP but the page you have created is asp.net.
To make your asp.net page work you will need the attached.  Also your inc file will need to be:
<%
Response.Write(DateTime.Now);
%>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="IncludeFiles._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

<body>

Blah, Blah .....

<p></p>

More blah, blah ...

<p></p>

<!--#include virtual="time.inc" --> 

 

</body>

</html>

 

TIME.ASPX

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

<body>

<%

    Response.Write(DateTime.Now);

%>

 

</body>

</html>

Open in new window

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:gabrielPennyback
Comment Utility
I feel like I'm taking you on a wild goose chase. I keep getting errors on the first line of TimeInclude.aspx. When I get rid of most of the Page definition elements causing the errors, I end up with Compiler Error Message: CS0103: The name 'Time' does not exist in the current context.
I actually don't have an aspx.cs doc or a web.config file. What would be the most minimal versions of those two files necessary for this thing to work?

Sorry for not being better prepared.

Thanks,
John
0
 
LVL 19

Expert Comment

by:daveamour
Comment Utility
Ok depends whether you want to be using Classic ASP or asp.net?
0
 
LVL 1

Author Comment

by:gabrielPennyback
Comment Utility
ASP.NET. Thanks :-)
0
 
LVL 1

Author Closing Comment

by:gabrielPennyback
Comment Utility
I think I figured out how to make your solution work. Thanks,
John
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now