|
Web Matrix Sample App
Open Web Matrix selecting from Start->Programs->Microsoft ASP.NET Web Matrix
from the start menu on your machine. You will find the New File Dialogue box that
looks like the image below.
Select ASP.NET page from the right column, specify a file name (Sample.aspx) and a
location on your hard drive where you want this file to be saved. Select Visual
Basic .NET from the Language drop-down box and click OK. Sample.aspx will open
in design view and will be ready for editing. In the design you will notice four button
towards the bottom which are marked as Design, HTML, Code and All. By default, Design
is highlighted which means that the document is in design view, to switch to HTML
view click the HTML button, to switch to code view select the Code button and to look
at HTML and Code side-by-side click the All button.
Drag a TextBox and a Button from the toolbox on to the page. The following code will
display "Welcome to Web Matrix" in the textbox when the button is clicked. The code
for that looks like this:
Sub Button1_Click(sender As Object, e As EventArgs)
TextBox1.text="Welcome to Web Matrix"
End Sub
|
Once you are finished with the code you need to run the page. You can run the page using
Web Matrix's built-in Web Server. Unlike Visual Studio. NET, ASP.NET Web Matrix doesn't
need IIS to test and run your page on the local machine. Web Matrix comes
with it's own built-in Web server. You can run the page by selecting
View->Start from the main menu or by holding F5 key
on the keyboard. Selecting any of the above option will display the Start Web Application
Dialog as shown in the image below.
As you can notice from the image above, there are two options in the Start Web
Application dialog box:
Use ASP.NET Web Matrix Server: Select this option to host the
web application using the built-in web server that ships with ASP.NET Web Matrix.
Note that the ASP.NET Web Matrix Server supports only local browser requests (for
security reasons). This means you cannot browse any of the pages remotely.
Use a new IIS Virtual Root: Select this option to host the web
application using the Microsoft IIS web server.
Click the Use ASP.NET Web Matrix Server option and type 8080 in the Application Port
box. Click the Start button. The Web Matrix server starts and you will notice
an icon in the system tray. On subsequent page runs, ASP.NET Web Matrix will use the
Web Server that was specified the first time you ran the page. ASP.NET Web Matrix
will not prompt you to specify a Web Server again until you either close and reopen
the ASP.NET Web Matrix development environment and run the page again or manually
shut down and restart the ASP.NET Web Matrix Server. The ASP.NET page you developed using
the code above will appear in a new instance of your Web browser. You can
test the page by clicking the button. When you click the Button, "Welcome to Web Matrix"
will be displayed in the TextBox.
Live Code Demo
|