Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 13th, 2007, 08:13 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Default ASP "Hello World"


I have written my first "Hello World" program in ASP. I thought I would post here how it is done and ask if anyone can suggest how to incorporate C#.

The first step was to download the free "Microsoft Visual Web Developer 2005 Express Edition" from microsoft.com

The next step was to install and run this program. Then create a new web page by clicking on File -> New Web Page. This will bring up this windowL

http://i67.photobucket.com/albums/h2...o/aspnet05.png

From this window, pick "ASP.Net Web Site" and click the OK button.

Then I edited the Default.aspx file so it reads like this:

Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%
    HelloWorldLabel.Text = "Hello, world!"
%>

<!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 runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Label runat="server" id="HelloWorldLabel"></asp:Label>

    </div>
    </form>
</body>
</html>
And this works.

So the next step is to incorporate C# into this "Hello World" program. Can anyone make a suggestion?


 
Old December 13th, 2007, 08:19 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You can not mix and match languages in the same project. You can, for example, create a class library in VB.NET and use the compiled .dll in a C# application. The equivelant C# code for the above example is:

protected void Page_Load(object sender, EventArgs e)
{
   HelloWorldLabel.Text = "Hello, world!";
}

also, in reality, your code above should be:
Protected Sub Page_Load(sender as object, e as EventArgs)
   HelloWorldLabel.Text = "Hello, World"
End Sub

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old December 14th, 2007, 02:12 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Doug,

You are slightly wrong here. If you are creating a "Web Site Project" (i.e. just a directory with pages and files in it) each page can be a different language. The ASP.NET runtime compiles each individual page separately on the fly. However, if you are use the "Web Application Project" it behaves like every other project type in VS.NET. All the files must be the same language because it compiles all files into the single assembly.

-Peter
 
Old December 14th, 2007, 09:38 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Thanks for the clarification Peter. I have never used the "Web Site Project" and was unaware of that particular functionality. Thanks.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
an 'Hello World' example for ASP.NET (.aspx) crmpicco ASP.NET 2.0 Basics 3 November 30th, 2006 11:35 AM
GRPS "Hello World" rodmcleay C# 0 October 11th, 2005 10:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.