Start up a project, and put a button inside the HTML page. To do this, go to View
| Toolbox
(Ctrl + Alt-X), type but
in the search field, and drag and drop the Button
control below the line that begins with <form id=...
. Change the text on the button to say Save File
.
Next, go to the Design
view. Double-click on the Save File
button. This brings up the event handler inside Default.aspx.cs
. Delete the Page_Load
stub. Collapse all of the comments above and below using System;
—you don't need them. The relevant portion of the starting code for this project should look like that in Figure 28.2.1:
Figure 28.2.1: The starting code for this project
First, let's add some namespaces. Enter the following after using System
near the top of the file:
using System.Xml; using System.Diagnostics;
You need using System.Diagnostics;
so that you can view a file in Internet Explorer and Notepad as soon as you create it.