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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very beginner - Result didn't show in the browser

Status
Not open for further replies.

not24

Programmer
Feb 25, 2002
68
US
I've got ASP.NET book for a while - just start reading it a few days. I'm using Visual Studio.NET 2003 on Windows XP.

I have some problem - I cannot see result of the code that I typed from the book. I've tried all the codes from few first chapters which's very easy writing "Hello World" - stuff like that. So I don't think it's a code. I think something in the setting in Visual Studio.NET or in my computer was not right. I went through VSS's Tools/Option but I have no clue what could have cause that.

Any codes similar to this one shown as blank page. It compiled - picked up all mistyped all right but it won't show the result!

Anyway, here is the code:
<%@ Page language="c#" Codebehind="listing06.aspx.cs" AutoEventWireup="false" Inherits="Day4.listing06" %>
<script runat="server">
void Page_Load(Object Sender, EventArgs e)
{
DateTime Now = DateTime.Now;
int intHour = Now.Hour;

Label1.Text = "The time is now " + Now.ToString("T") + "<p>";

if (intHour < 12)
{
Label1.Text += "Good morning!";
}
else if (intHour > 12 & intHour < 18)
{
Label1.Text += "Good afternoon!";
}
else
{
Label1.Text += "Good evening!";
}
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>listing06</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content=" </HEAD>
<body>
<form runat="server">
<asp:Label ID="Label1" Runat="server" />
</form>
</body>
</HTML>

Another thing is "Statment Completion set to auto list members but it never list any members while I typing the code under <script>...</script> block (for example when I typed Response. and I supposed it show a list so I can select "Write") but it would list member of <asp:xxx>. Is it how it works?
 
Sounds like you done't have ASP.NET installed properly. There's the old aspnet_regiis
command that will fix that. Please search this forum for more info on that.

Unfortunatly, Intellisense (the auto-completion you're taking about) doesn't work for server script blocks on .aspx files. Only in the codebehind (.vb or .cs files). I think that is getting addressed in VS.NET 2005.

[pipe]
Share your knowledge! -
 
Thank you for your suggestion but I also run same code on my work computer (which for testing somebody else's ASP.NET application so I have everything on this computer) and it did the same thing - show blank page.

Could it be something else?
 
I can only see the HTML code following this when I was testing the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>test</title>

<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content=" </HEAD>
<body>
<span id="lblMessage"></span>
</body>
</HTML>
 
Here
Code:
<%@ Page language="c#" Codebehind="listing06.aspx.cs" AutoEventWireup="false" Inherits="Day4.listing06" %>
<script runat="server">

This says you are using codebehind. Either take the code out of your <script> tags and put it in the codebehind file, or chage the AutoEventWireup to true, delete the codebehind file and remove the Codebehind and Inherits attributes from the Page directive. As it is now, AutoEventwireup is false so your Page_Load method is not firing.

[pipe]
Share your knowledge! -
 
It's work - finally. Thanks a lot!

Unfortunately, the book that I'm reading, the author using notepad as editor so I didn't know what all those mean. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top