Compilation Errors


The first thing to look at is errors that happen during compilation. Since ASP.NET pages are compiled when they are run, this can be fairly alarming when you first see it, but don't worry. If we go by my experience, most of these will just be typing errors!

Try It Out—A Compilation Error

  1. Create a new ASP.NET Page, called CompileError.aspx.

  2. Add a Label and a Button to the page.

  3. Double-click the button to get to the code window, and type the following in:

     Label1.Test = "Some Text" 

    Type it in exactly as it is here – there's a deliberate error.

  4. Save the page and run it:

    click to expand

How It Doesn't Work!

Well, it's somewhat obvious what's wrong from the error message:

'Test' is not a member of 'System.Web.UI.WebControls.Label'.

We simply mistyped the property name, using Test instead of Text. However, what's important is seeing what happens and understanding the error. On the above screen you can see the source code is shown with the line containing the error highlighted. There are two links on the page that allow us to see more detailed information – you can click them if you like, but for most errors you'll find the default details give enough information. We're not going to look at these here, but the .NET documentation has more details on them.

Fixing the error is simply a matter of correcting the typing mistake and trying again.




Beginning Dynamic Websites with ASP. NET Web Matrix
Beginning Dynamic Websites: with ASP.NET Web Matrix (Programmer to Programmer)
ISBN: 0764543741
EAN: 2147483647
Year: 2003
Pages: 141

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net