Wei-Meng Lee - C# 2008 Programmer's Reference

Здесь есть возможность читать онлайн «Wei-Meng Lee - C# 2008 Programmer's Reference» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Indianapolis, Год выпуска: 2009, ISBN: 2009, Издательство: Wiley Publishing, Inc., Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

C# 2008 Programmer's Reference: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «C# 2008 Programmer's Reference»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

C# 2008 Programmers Reference provides a concise and thorough reference on all aspects of the language. Each chapter contains detailed code samples that provide a quick and easy way to understand the key concepts covered.

C# 2008 Programmer's Reference — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «C# 2008 Programmer's Reference», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

width: 350px;

}

...

The .modalBackgroundstyle 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 .dialogstyle 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 control to the GridViewcontrol to display a Delete button:

AllowPaging="True" AllowSorting="True"

AutoGenerateColumns="False"

BackColor="LightGoldenrodYellow"

BorderColor="Tan"

BorderWidth="1px" CellPadding="2"

DataKeyNames="title_id"

DataSourceID="LinqDataSource1"

ForeColor="Black" GridLines="None">

ShowEditButton="True" ShowSelectButton="True"/>

HeaderStyle-Width="60px"

ItemStyle-HorizontalAlign="Center">

OnClick="btnDelete_Click"

OnClientClick="displayPopup(this); return false;"

Text="Delete"/>

HeaderText="title_id"

ReadOnly="True" SortExpression="title_id"/>

HeaderText="title1" SortExpression="title1"/>

...

Notice that the Delete button has two events defined: OnClickand 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 GridViewcontrol because you now have the Delete button. Set the ShowDeleteButtonattribute in the element to False:

ShowDeleteButton="False"

ShowEditButton="True"

ShowSelectButton="True"/>

The Default.aspx page now looks like Figure 17-29.

Figure 1729 Create a new folder in the project and name it images Add an - фото 316

Figure 17-29

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

Figure 1730 You will now use a element to define the content of the popup - фото 317

Figure 17-30

You will now use a

element to define the content of the popup that you want to display:



class="dialog" style="display:none">



src="images/delete.png" width="60"/>

Are you sure you want to delete this record?

Text="Yes" Width="50px"/>

Text="No" Width="50px"/>

This block of code defines the popup shown in Figure 17-31.

Figure 1731 To display the element as a modal popup use the - фото 318

Figure 17-31

To display the

element as a modal popup, use the ModalPopupExtendercontrol:

TargetControlID="divDialog" PopupControlID="divDialog"

OkControlID="btnOK" CancelControlID="btnNO"

OnOkScript="OK_Click();" OnCancelScript="No_Click();"

BackgroundCssClass="modalBackground">

The ModalPopupExtendercontrol has the attributes described in the following table.

Attribute Description
ID Identifies the ModalPopupExtendercontrol
TargetControlID Specifies the control that activates the ModalPopupExtendercontrol
PopupControlID Specifies the control to display as a modal popup
OkControlID Specifies the control that dismisses the modal popup
CancelControlID Specifies the control that cancels the modal popup
OnOkScript Specifies the script to run when the modal popup is dismissed with the OkControlID
OnCancelScript Specifies the script to run when the modal popup is canceled with the CancelControlID
BackgroundCssClass Specifies the CSS class to apply to the background when the modal popup is displayed

Finally, insert the JavaScript functions into the source view of Default.aspx:

var _source;

var _popup;

function displayPopup(source) {

_source = source;

_popup = $find('popupDialog');

//---display the popup dialog---

_popup.show();

}

function OK_Click() {

//---hides the popup dialog---

_popup.hide();

//---posts back to the server---

__doPostBack(_source.name, '');

}

function No_Click() {

//---hides the popup---

_popup.hide();

//---clears the event sources

_source = null;

_popup = null;

}

The displayPopup()function looks for the ModalPopupExtendercontrol in the page and displays the modal popup. The OK_Click()function is called when the user decides to proceed with the deletion. It hides the modal popup and initiates a postback to the server. The No_Click()function is called when the user cancels the deletion. It hides the modal popup.

That's it! Press F5 to test the application.

In this particular example, you will get a runtime error if you proceed with the deletion. That's because the titlestable is related to the titleauthortable (also part of the pubsdatabase), and deleting a record in the titlestable violates the reference integrity of the database.

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «C# 2008 Programmer's Reference»

Представляем Вашему вниманию похожие книги на «C# 2008 Programmer's Reference» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «C# 2008 Programmer's Reference»

Обсуждение, отзывы о книге «C# 2008 Programmer's Reference» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x