The web form renders with three Label controls that all generate the same
JavaScript alert pop-up when clicked. The following HTML code shows the
tags and
their inline client-side JavaScript:
Click the TopLabel
Click the MiddleLabel
Click the BottomLabel
Figure 8-1 shows what happens when the middle ClickLabel text output is clicked.
Figure 8-1. The Click web form after the middle label is clicked
CHAPTER 8 ?– INTEGRATING CL IENT-SIDE SCRIPT 351
The full code for the web form is shown in Listings 8-2 and 8-3.
Listing 8-2. The Click Web Form .aspx Page File
<%@ Page Language="C#"
MasterPageFile="~/MasterPage/ControlsBook2MasterPage.Master"
AutoEventWireup="true" CodeBehind="Click.aspx.cs"
Inherits="ControlsBook2Web.Ch08.Click" Title="Click Demo" %>
<%@ Register Assembly="ControlsBook2Lib" Namespace=
"ControlsBook2Lib.Ch08" TagPrefix="apress" %>
"ChapterNumAndTitle" runat="server">
Width="14px">8 ID="ChapterTitleLabel" runat="server" Width="360px">
Integrating Client-Side Script
Ch08 Click Event Handling
"Click the TopLabel" onclick="alert('TopLabel clicked!');" />
"Click the MiddleLabel" ClickText="MiddleLabel clicked!" />
Listing 8-3.
Pages:
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464