...
The .modalBackground
style defines the background color of the modal popup. In this case, it is used to block off the rest of the page and prevent the user from interacting with that content. The .dialog
style defines the shape and color of the popup itself. Here it has a rectangular border of 5px and a width of 350px.
Next, add a <asp:Template>
control to the GridView
control to display a Delete button:
<asp:GridView ID='GridView1' runat='server'
AllowPaging='True' AllowSorting='True'
AutoGenerateColumns='False'
BackColor='LightGoldenrodYellow'
BorderColor='Tan'
BorderWidth='1px' CellPadding='2'
DataKeyNames='title_id'
DataSourceID='LinqDataSource1'
ForeColor='Black' GridLines='None'>
<Columns>
<asp:CommandField ShowDeleteButton='True'
ShowEditButton='True' ShowSelectButton='True'/>
<asp:BoundField DataField='title_id'
HeaderText='title_id'
ReadOnly='True' SortExpression='title_id'/>
<asp:BoundField DataField='title1'
HeaderText='title1' SortExpression='title1'/>
...
Notice that the Delete button has two events defined: OnClick
and OnClientClick
. In this example, when the user clicks the button, the JavaScript function named displayPopup()
(which you will define shortly) is called. You insert the return false;
statement to prevent a postback from occurring while the dialog is being displayed.
You also need to disable the Delete link in the GridView
control because you now have the Delete button. Set the ShowDeleteButton
attribute in the <asp:CommandField>
element to False:
<asp:CommandField
ShowEditButton='True'
ShowSelectButton='True'/>
The Default.aspx page now looks like Figure 17-29.

Figure 17-29
Create a new folder in the project and name it images
. Add an image called delete.png
into the images folder (see Figure 17-30).

Figure 17-30
You will now use a <div>
element to define the content of the popup that you want to display:
</form>
</body>
</html>
This block of code defines the popup shown in Figure 17-31.

Figure 17-31
To display the <div>
element as a modal popup, use the ModalPopupExtender
control:
</form>
</body>
</html>
The ModalPopupExtender
control has the attributes described in the following table.