Learning: ajaxtoolkit: confirmbutton in repeater)

Source: Internet
Author: User
Tags microsoft sql server 2005 microsoft sql server management studio sql server management sql server management studio
Using a confirmbutton in a repeater

Christian Wenz

Overview

The confirmbutton extender in the Ajax Control Toolkit creates a yes/no popup when the user clicks on a button (including linkbutton control ). only if yes is clicked, the button's action is executed, otherwise canceled. this is also possible in 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 http://go.microsoft.com/fwlink? Linkid = 64064. The adventureworks database is part of the SQL Server 2005 samples and sample databases (download at http://www.microsoft.com/downloads/details.aspx? Familyid = e719ecf7-9f46-4312-af89-6ad8702e4e6e & displaylang = EN). The easiest way to set the database up is to use the Microsoft SQL Server Management studio Express (http://www.microsoft.com/downloads/details.aspx? Familyid = c243a5ae-4bd1-4e3d-94b8-5a0f62bf7796 & displaylang = EN) and attach the adventureworks. MDF database file.

For this sample, we assume that the instance of the SQL Server 2005 express edition is calledSqlexpressAnd 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,ScriptmanagerControl must be put anywhere on the page (but within<Form>Element ):

<Asp: scriptmanager id = "ASM" runat = "server"/>

Then, a data source is required. for the sake of simplicity, only the first five entries in adventureworks 'vendors table are retrieved. note that when using the Visual Studio Wizard to create the data source, the table name (Vendors) Is currently not correctly prefixedPurchasing. The following markup is the correct one:

<Asp: sqldatasource id = "sds1" runat = "server" connectionstring = "Data Source = (local) \ sqlexpress; initial catalog = adventureworks; integrated Security = true "providername =" system. data. sqlclient "selectcommand =" select top 5 [vendorid], [name] from [purchasing]. [Vendor] "/>

This data source can be then be used within a repeater. As usual,Databinder. eval ()Method retrieves data from the data source.ConfirmbuttonextenderControl must then be placed within<Itemtemplate>Section of the repeater so that it appears for every entry in the data source.

<Div> <ul> <asp: repeater id = "rep1" performanceid = "sds1" runat = "server"> <itemtemplate> <li> <% # databinder. eval (container. dataitem, "name") %> <asp: linkbutton id = "btn1" text = "remove item" runat = "server"/> <ajaxtoolkit: confirmbuttonextender id = "cfe1" runat = "server" targetcontrolid = "btn1" confirmtext = "Are you sure ?! "/> </LI> </itemtemplate> </ASP: repeater> </ul> </div>

 

The confirm button appears next to each entry from the data source(Click to view full-size image)

 

It come from: http://www.asp.net/ajax/tutorials/using-a-confirmbutton-in-a-repeater-cs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.