03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

710 x CHAPTER 18 EXCEPTION HANDLING, DEBUGGING, AND TRACING<br />

FIGURE 18-20<br />

3. Press F5 to start debugg<strong>in</strong>g. The page loads <strong>in</strong> the browser <strong>and</strong> you get a text box <strong>and</strong> two buttons.<br />

Enter your name <strong>in</strong> the text box <strong>and</strong> click the Say Hello button. As soon as you click it, focus is put<br />

back on Visual Studio, <strong>and</strong> the code halts <strong>in</strong> the JavaScript code block.<br />

COMMON MISTAKES If your client-side JavaScript breakpo<strong>in</strong>t doesn’t get hit,<br />

close your browser to stop debugg<strong>in</strong>g, type the word debugger before the l<strong>in</strong>e<br />

you set the breakpo<strong>in</strong>t on, <strong>and</strong> press F5 aga<strong>in</strong>. VS does not always correctly<br />

debug your client-side JavaScript breakpo<strong>in</strong>ts, but it works fi ne when us<strong>in</strong>g the<br />

debugger keyword:<br />

debugger<br />

var yourName = document.getElementById('YourName').value;<br />

NameService.HelloWorld(yourName, helloWorldCallback);<br />

4. Press F10 to execute the highlighted l<strong>in</strong>e (you need to press it<br />

twice if you’re us<strong>in</strong>g the debugger keyword). The value <strong>in</strong> the<br />

text box is now assigned to the yourName variable. When you<br />

hover your mouse over that variable, a data tip appears.<br />

5. Open the other debugg<strong>in</strong>g w<strong>in</strong>dows <strong>and</strong> notice how they<br />

all behave identically to what you saw before. You can add<br />

JavaScript variables to the Watch w<strong>in</strong>dow to look at their values,<br />

enter JavaScript <strong>in</strong> the Immediate w<strong>in</strong>dow for evaluation, <strong>and</strong> so<br />

on. Also note that the Solution Explorer has changed, show<strong>in</strong>g the<br />

active client-side files conta<strong>in</strong><strong>in</strong>g script right above the web project<br />

(see Figure 18-21).<br />

6. To look <strong>in</strong>side these documents, you can double-click them under<br />

the W<strong>in</strong>dows Internet Explorer node that has appeared <strong>in</strong> the<br />

Solution Explorer. The file WebServices.aspx should already<br />

FIGURE 18-21<br />

be open <strong>in</strong> the Document W<strong>in</strong>dow. At first, the file may look like<br />

before. But if you look closely, you can see that this is no longer the orig<strong>in</strong>al source file with <strong>ASP</strong>.<br />

<strong>NET</strong> controls mixed up with other markup, but the f<strong>in</strong>al HTML rendered <strong>in</strong> the browser.<br />

To warn you that you are look<strong>in</strong>g at the f<strong>in</strong>al file, <strong>and</strong> not the orig<strong>in</strong>al source, VS has added the<br />

text [dynamic] <strong>and</strong> a lock icon to the tab for the file above the Document W<strong>in</strong>dow, shown <strong>in</strong><br />

Figure 18-22.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!