Subscribe to RSS Feed

Your source for C# and ASP.NET software developmet

Getting Started with ASP.NET (Part 1): "Hello World"

So you want to develop web applications with ASP.NET? Fair enough. You've got a lot to learn, of course. There's some incredible technology running under the hood of each and every ASP.NET web application, and you're not going to understand all of it overnight. That said, once you do grasp the technology, you will have some incredibly powerful tools for rapid and robust web application development at your fingertips.

However, if you are like me, you'll want to jump in and learn the technology as you go. For this reason, I am putting together a series of articles to help you get accustomed to Visual Studio, ASP.NET, and the .NET framework as a whole. Basically, I'll show you what I wish I had when I was starting out. The infamous Hello World application is a good place to start. I'll show you three ways to accomplish this in ASP.NET

Okay, let's get started. Open up Visual Studio. I'll be using Visual Studio 2008 here, but 2005 will work as well. If you don't have either, you should download Microsoft's Visual Web Developer 2008 Express. VWD Express provides all the functionality we'll need to get through this series. The certainly are many differences between Visual Studio and VWD Express, but that's another article.

When your IDE of choice is open, create a new Project by opening the File menu, hovering your cursor over "New," and selecting "Project..." as shown below.

Click on "Project" under File -> New

On the dialog that pops up, select "ASP.NET Web Application", under the "Web" project type. Name the project "HelloWorld." A project is a unit of compilation, or, in other words, a container for the files you'll create for your application. Click the image thumbnail to view it at full-size.

 

Select "ASP.NET Web Application" as the project type and enter the name "HelloWorld."

At this point, the HelloWorld project will be created and the Visual Studio (or VWD) view will change. You will be presented with the contents of the "Default.aspx" file. Default.aspx is, as its name implies, the default page that will be shown for your application, much like index.html for a static HTML project. What you are viewing is ASP markup, which is a mix of ASP.NET tags and HTML. Since we don't know any ASP.NET code yet, let's switch to Visual Studio's WYSIWYG view, Design mode. You can switch to Design mode by clicking on "Design" at the bottom of the file editor.

Click "Design" to switch to Design mode

In Design mode, we see that we have an empty page (no, that's not en error - you have not added any content yet!) We're trying to show "Hello World!" to the world, and this is a WYSIWYG editor, so just type it in. The text should appear within the div tag, as shown.

Type "Hello World!" within the div tag

That's it! Let's start out application so we can see if it compiles and runs correctly. Select "Start Without Debugging" from the "Debug" menu.

Select "Start Without Debugging" from the Debug menu

You should notice that a popup message appears in your task bar noting that the ASP.NET Development server is running. This means that Visual Studio has started a service on your local computer that allows your computer to behave like a real webserver and host your application. It'll continue to run until we decide to end the runtime session, which, in our case, will end when we close Internet Explorer.

This dialog will be shown in your taskbar.

More importantly, Internet Explorer will open and display the Default.aspx page to us. Hopefully, it looks like this:

Our "Hello World' application running in Internet Explorer

Congratulations! You've just created and run your first ASP.NET web application. Excited yet? I hope so, because we've got more to cover here. Design mode is nice, but it doesn't always provide us with the granularity of control that we want when designing pages. Let's switch to Source mode, which is what we were started in originally. Do this by clicking "Source" at the bottom of the editor. Then, remove the existing "Hello World!" text. Replace it with the following code:

<%= "Hello World" %>

 

This is what's called an "inline expression." It is a type of ASP tag that inserts the value of the expression into the page at runtime. The quotes are necessary because we are providing a string expression. If they were omitted, it would try to evaluate them just like any other C# code. We will look at using inline expressions, other code render blocks, and examine the other ASP tags in another article. For now, ensure that your Default.aspx page looks like this one:

Switch to Source mode and insert the inline expression code

Run the application again by using the Start Without Debugging command. You're going to be using this a lot, so you should probably learn the keyboard shortcut for it (Ctrl+F5). Verify that "Hello World!" is shown again, and close Internet Explorer. Cool! Two out of three ways of showing "Hello World" down. Now, let's take a look at how we can combine Design mode and Source mode so we can get both a preview of our page and granular control over its contents. Visual Studio provides a way for us to view both at the same time. Click on "Split" at the bottom of the editor, as below, to switch to this mode.

Switch to "Split" mode

Next, we're going to look at the Toolbox. The Toolbox contains all of the nifty little toys that Microsoft has provided us with for developing our applications quickly. It's pretty extensive, and rightly so. Why should we have to rewrite code for features that are included in almost every web application? By default, the Toolbox (shown below), should reside to the left of the editor frame. You may have to click on a "Toolbox" button to get it to display, depending on your resolution.

The Visual Studio Toolbox

Each entry in the Toolbox is called a control, and the controls run the gamut from displaying text, to providing a file upload feature, to handling user login. Each control can be dropped into your page (into either the Design window or the Source window), and then configured to match your needs. We're interested in display text here, so double click on the Label control. Visual Studio will insert a label control at your cursor. Notice that you can see both the ASP tag representing the Label in Source mode and the appearance of the Label in Design mode. It should look like this:

A Label control shown in Split mode

If you click on the Label in the design window, we'll see another important Visual Studio pane: the Property Editor. By default, this is shown in the bottom-right corner of the IDE. The image below highlights a few things you should notice about the property window. When the Label is selected, its name is shown in the first line of the Property Editor. Likewise, its properties are shown for direct editing. The Text property is highlighted, and its value is Label. Looking at the tip displayed, we see that the Text property represents the text that the label shows. Ah-ha! It is currently set to "Label," so that is why Design mode shows what it does. Let's change that to "Hello World!" as shown (quotes not required here - Visual Studio will insert them for us.)

Text property of our Label editted to "Hello World!"

Notice that Visual Studio updates both our Design and Source views to show the new value of the Text property for Label1. Run this application one final time to verify that it works. If you've forgotten the keyboard shortcut, I'll remind you that it's Ctrl+F5, but don't let it happen again!

So, we've gotten our Hello World application running three different ways (pure HTML, inline expressions, and the Label control), and learned the basics of moving around within Visual Studio. Like I said, we've got a lot of ground to cover still, but this is a good start. This was an image-heavy post, but that was appropriate for your first tutorial. Please don't expect them all to be like this. In future articles, I will use less images, but I am as-wordy, at the very least. Please feel free to post any questions you have.

Next article: Getting Started with ASP.NET Part 2: Code-behind and Events >>

  • Share/Save/Bookmark

Comments

  • Raul Roa said:

    You should add Response.Write("Hello World!"); on the Page_Load event to the list.

  • Josh Jordan (Author) said:

    This is true, but I didn't want to introduce the concept of code-behind in this article. I was going to start the next entry in the series with some simple events, and that sounds like a great way to start. Thanks for the suggestion!

  • Stephen Forcucci said:

    Clipboard in step 2 doesn't work - well, it works, but the " (quotation marks) it uses don't appear to work when directly pasting it into VWD. Works fine if you delete and retype them or just type the whole thing in manually.

  • Josh Jordan (Author) said:

    Ah, I see the problem. When the article is published, the quotation marks are processed and "beautified" into directed quotation marks, as in the title of article. I solved this problem by using the HTML character code for quotation marks. This is a bit frustrating - I'll have to remember to do this in future articles.

    Thanks for the heads up.



Recent Archives
  • bernstein plays brubeck plays bernstein
  • masonic telluride co
  • assay chateau france
  • advise on having passports for cruises
  • dvd decrypter forum
  • molecular flourescence spectroscopy
  • lakeview mental health in waxahachie tx
  • accesorios gatos
  • idleriot.com
  • blue ridge community college rockingham va
  • info on canadas history
  • coca cola report spoof email
  • fms flight
  • caretakersnetwork.org
  • approved wieght loss medications
  • association on developmental disability
  • are pigs intelligent
  • bath showroom ub and shower connecticut
  • impeller mercury outboard engine
  • antique veils
  • ayers jean
  • education for a librarian
  • 16 dicharge hose
  • filetonic.com
  • highly textured films
  • rejesus.co.uk
  • distans between uranas neptune and pluto
  • american kittens jenny home
  • greg normal shop santee sc
  • gimp and hanvon tablet
  • 5 subject wide rule with pockets
  • cat advise for free
  • shiva and death rituals among jews
  • 25 bitham mill courtyard
  • search-photo.com
  • all saints church kent england
  • 3d garden planner
  • sunglassesbox.com
  • ballet flats with jewels
  • cinnamon club devonshire square
  • difflearn.com
  • grupo aventura te vi
  • cateye hike
  • boston gourmet food baskets
  • clorox on concrete
  • codes for fable for xbox
  • aj davis
  • house of raja
  • nj segway enthusiasts
  • actix india pvt ltd
  • autumn hymn
  • blueangels.org
  • adriana silva
  • youcouponplace.com
  • a tribute to willie nelson
  • epdq.co.uk
  • alabaster waterboard
  • allen hicks selma al
  • alhambra hotel and kingston
  • incall massage long island
  • hanna barbera cartoons on
  • aikidoai.com
  • greater moncton multicultura associatin
  • hannity debate
  • anti-theft waist belt
  • discountspaparts.com
  • 1776 mccullough book discussion questions
  • albuquerque burrito
  • 3d ocean view video screansaver
  • 1987 toyota corolla specs
  • looney toon names
  • another woman wants my husband
  • maletower.com
  • abb c-e nuclear power
  • fransisco ayala the last supper
  • advantages of mechanistic structure
  • arvo part fur alina
  • acipco employment jasper al
  • 4 basic design principles
  • alan jacksons home
  • bulk mulch illinois
  • academic freedom letters professor states university
  • ferialatinaonline.com
  • farris day off quotes
  • foreigner on tour
  • aaron copland organ symphony
  • bermuda wallis and futuna xml syndication
  • imformation of computer
  • incubus break up
  • big oily asses
  • 2005 property tax credit forms
  • aeroflex motion control devices
  • foriegn cars italia
  • bulimic complications
  • cactus tree joni mitchell
  • bookmark hot button icon facebook del
  • jess arabian ranches
  • guerilla air paintball
  • calculating intrest
  • maybe ill catch fire
  • antofagasta plc
  • ford taurus sho throttle cable
  • abf international and albert brush fod
  • curious george candy wrappers
  • gsa martinsburg wv
  • emploi environnement developpement durable liens
  • carousel cannington
  • hammarlund transmitters
  • desi chokri
  • casing pantech duo
  • berkley jensen plastic ware
  • agents platforms report car
  • betty millan cultura brasileira
  • cd-rom replication toronto
  • georgia garnishment
  • mary neilson domain ca
  • famouse artists snow globes
  • infomercial back exercise equipment
  • roughguides.com
  • definition for pastoral poem
  • booblicious.net
  • victorias pet store fondulac wisconsin
  • citirl.com
  • 3d computer art from members
  • auditory discrimination activities free
  • arab girls head coverings
  • singing-wings-aviary.com
  • chrono cockpit 786
  • disgaea etna shrine
  • goodies on las tunas in ca
  • answers to vmk quests
  • final fantasy tactics guide ps1
  • kiaparts.com
  • at t bonds
  • horse pasture grass mixes
  • moonlight wavelength emulations
  • huntingdon county pennsylvania genealogy
  • bluegrassville.com
  • crab stuffed filet mignon
  • buttermilk sour cream biscuits
  • 14 magazine
  • kimberley aquatic centre
  • scottland ferry in surry virginia
  • 91 maxima stalls
  • 12 volt side of life
  • beef stew recipe slow cooker
  • free storys threesomes
  • 1680d ripstop nylon duffel
  • blue painted european dollhouse furniture
  • kino theatre melbourne
  • big bend fossils
  • american downhill ski team
  • debts left on survivor in arizona
  • antique candle sconce
  • adapter tube nikon 5400
  • jcics.org
  • ann ennis
  • blood sweat and tears original band
  • electrostatic map of nonpolar molecules
  • penelope pitstop racecar
  • exporters of diesel engine in india
  • actors who have played aladdin
  • aisleyne big brother nuts
  • 2080 highwood mn
  • futurama comic books
  • sillyasstoys.com
  • americas richest people
  • whoisjesus-really.com
  • decorator cots
  • glasstilestore.com
  • can acupuncture damage nerves
  • alerts applications marketing august unsubscribe
  • aster quest
  • american pride tshirts
  • 28 gauge twist ties
  • elvis are you lonesome to night
  • metabolic engineering of cofactors nadh nad
  • auto train to disneyland
  • easyarticles.com
  • breezy point ice arena
  • cng filling station
  • aero-naut vampire
  • 2nd thought
  • alkaline trio merch
  • adderal negative comments
  • 12 volt halogen bulb
  • bethel christain fellowship rochester ny
  • becoming a sushi chef
  • advice debt management us
  • entourage 2008 no out of office
  • albert snider elizabeth bennett
  • about hardwood flooring
  • hoopsking.com
  • alien remains aftermarket trigger
  • avocado avenue by jacinto jesus cordona
  • skrappy.org
  • alabama governor rufus willis cobb
  • detroit sightseeing
  • a thatcher
  • discount jogging strollers
  • nini rosso silencio
  • antiques and collectibles at rockaway beach
  • avon 320 jet
  • back spasm remedy
  • attiva gym barbados
  • janelle brouwer
  • janelle crawford
  • blacks and picnic
  • sydneycosmeticclinic.com.au
  • brookside free methodist church kokomo indiana
  • thehotrodcompany.com
  • allen castle family texas crane
  • 2 stroke volume calculations pistons
  • bark buddies tree decor
  • tabslyricschords.com
  • yanmar 1510 tractor
  • yanmar 1 gm manual
  • jaw stiff and ear hissing
  • 3gcs.com
  • definition of managerial hierarchy
  • brands carrying ground turkey and tenderloins
  • amber strobe
  • growth of cities in gilded age
  • antique brass formed hinge
  • 13 colonies resources
  • composting lavatory uk
  • alli and weight watchers
  • line loc install
  • all of the babs writings
  • 24x54 above ground pools
  • delilahsdirtydebutantes.com
  • apartments for rent in milton florida
  • myfaucet.info
  • brit brit
  • 1717 connecticut ave saint cloud fl
  • 3d studio max 8 training class
  • mosaicglasstileent.com
  • champ ix pfizer
  • a dialog box is open
  • arthur erikson houses
  • chinese cooking knives in guangzhou china
  • alkalis dissolve into skimmer cones
  • 4 debt relief usa
  • download-reactor.com
  • aaa northern region
  • insomniagallery.com
  • childhood teasing and bullying
  • 154 rome solution snowboard
  • boston ballet school teacher andrew kelley
  • alias file unix
  • 96.1 near baton rouge la
  • cheapest fligts europe russia
  • mixonic.com
  • cities and populations
  • 1994 bonneville plenum replacement
  • 2 color banner material wholesale
  • delaware county doberman rescue
  • billy robinson of gastonia nc
  • clogged basement floor drain
  • keihin mikuni crossreference
  • gotta be somebody lyrics nickelback
  • cheap honda crx
  • 17 computer bags
  • knvotv48.com
  • audi catalytic converter
  • ogletree eyecare
  • cinamon buns
  • biography of lorenzo de medici
  • cool gadgets gizmos
  • 2004 trailblazer instrument cluster
  • histoire state express 555
  • ambient information visualization
  • mick bos gas
  • messianiclife.com
  • austin wyndham garden hotel music photos
  • cat tails golf coarse
  • dptv.org
  • publix columbus ga
  • 351 windsor short blocks
  • chesapeakegrc.org
  • catholic lutheran communion
  • 410 sprint ringtone
  • constable arthur bowen rcmp
  • faheysales.com
  • 1010 deere
  • 1virgins.net
  • fannie mae freddy mac contributions
  • franchising em portugal
  • tuepaid.com
  • kosovo 2007
  • atv lifts
  • donne francesi
  • analdreamhouse.com
  • camp longhorn burnet texas
  • appointment of nj fee arbitration panel
  • dave duval
  • blitzusa.com
  • ct state varmint
  • 8n tractor liner sealer
  • goode modified t tube
  • toysandjoys.com
  • ccompare garmin nuvi 650 w
  • download singapore prosperity mcdonalds
  • indentured servants carolinas
  • .32 h r magnum origin
  • conyers ga marrige licence
  • aix ntp client
  • 2008 mwr award ft knox
  • are miscarriages genetic
  • baroque christmas ornament
  • digital photography cameras exilim
  • great midwestern cafe in clive
  • accounting jobs in saudi arabia
  • australian rules football standings
  • brian pitts recruiter birmingham alabama
  • pepe biondi
  • providingmignonne.com
  • 5w marine vhf maximum range
  • abs pipe plant grower
  • ablert pike ar
  • shmula.com
  • 1984 nba all star game
  • cost to attend grantham university
  • addition of probability distributions
  • anonymous toolbar
  • edward james olmos selena
  • animal miracles singing horse
  • 50s satin jacket
  • baumannii botanical