Skip to content

Latest commit

 

History

History
50 lines (32 loc) · 4.11 KB

using-modalpopup-with-a-repeater-control-cs.md

File metadata and controls

50 lines (32 loc) · 4.11 KB
uid title author description ms.author ms.date ms.assetid msc.legacyurl msc.type
web-forms/overview/ajax-control-toolkit/modalpopup/using-modalpopup-with-a-repeater-control-cs
Using ModalPopup with a Repeater Control (C#) | Microsoft Docs
wenz
The ModalPopup control in the AJAX Control Toolkit offers a simple way to create a modal popup using client-side means. It is also possible to use this contr... (C#)
riande
06/02/2008
d686d84a-1c58-492e-8a77-3eb5a0cfe918
/web-forms/overview/ajax-control-toolkit/modalpopup/using-modalpopup-with-a-repeater-control-cs
authoredcontent

Using ModalPopup with a Repeater Control (C#)

by Christian Wenz

Download PDF

The ModalPopup control in the AJAX Control Toolkit offers a simple way to create a modal popup using client-side means. It is also possible to use this control within a repeater.

Overview

The ModalPopup control in the AJAX Control Toolkit offers a simple way to create a modal popup using client-side means. It is also possible to use this control within a repeater.

Steps

First of all, a data source is required. This sample uses the AdventureWorks database and the Microsoft SQL Server 2005 Express Edition. The database is an optional part of a Visual Studio installation (including express edition) and is also available as a separate download under https://go.microsoft.com/fwlink/?LinkId=64064. The AdventureWorks database is part of the SQL Server 2005 Samples and Sample Databases (download at https://www.microsoft.com/download/details.aspx?id=10679). The easiest way to set the database up is to use the Microsoft SQL Server Management Studio (/sql/ssms/download-sql-server-management-studio-ssms) and attach the AdventureWorks.mdf database file. For this sample, we assume that the instance of the SQL Server 2005 Express Edition is called SQLEXPRESS and resides on the same machine as the web server; this is also the default setup. If your setup differs, you have to adapt the connection information for the database. In order to activate the functionality of ASP.NET AJAX and the Control Toolkit, the ScriptManager control must be put anywhere on the page (but within the <form> element):

[!code-aspxMain]

Then, add a data source to the page. In order to use a limited amount of data, we only select the first five entries in the Vendor table of the AdventureWorks database. If you are using the Visual Studio assistant to create the data source, mind that a bug in the current version does not prefix the table name (Vendor) with Purchasing. The following markup shows the correct syntax:

[!code-aspxMain]

Next, add a panel which serves as the modal popup. It contains a Button control to close the popup again:

[!code-aspxMain]

In order to make the popup work within the repeater, the ModalPopupExtender control must be put within the <ItemTemplate> section of the repeater. So the panel is outside the repeater, but the extender is inside. Here is the markup for the repeater:

[!code-aspxMain]

Then, every item in the data source is displayed with a button next to it that triggers the modal popup.

The modal popup can be triggered for every data source entry

The modal popup can be triggered for every data source entry (Click to view full-size image)

[!div class="step-by-step"] Previous Next