© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies

  HomeSource Code DotNet ► Asp.Net ▼

User Confirmation before deleting items

          IT describes how ASP.Net 2.0 allows setting client-side functions for Button controls through the use of the OnClientClick property and additionally, the event can be handled on server-side depending on the user response.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>

<form id="form1" runat="server">

<div>

<strong><span style="font-size: small; font-family: Arial; text-decoration: underline">

Contacts Listing </span></strong>

<br />

<br />

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

DataSourceID="SqlDataSource2" EmptyDataText="There are no data records to display." style="font-size: small; font-family: Arial" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical">

<Columns>
    <asp:BoundField DataField="id" HeaderText="Person ID" SortExpression="id" />
    <asp:BoundField DataField="fname" HeaderText="First Name" SortExpression="fname" />
    <asp:BoundField DataField="lname" HeaderText="Last Name" SortExpression="lname" />
    <asp:BoundField DataField="phone" HeaderText="Phone Number" SortExpression="phone" />

<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton runat="server" ID="btnDelete" CommandName="Delete"

OnClientClick="return confirm('Are you sure you want to delete this Contact Record?');" Text="Delete" ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" />

<RowStyle BackColor="#F7F7DE" />

<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />

<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />

<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />

<AlternatingRowStyle BackColor="White" />

</asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:csharpConnectionString2 %>"
        SelectCommand="SELECT * FROM [contactperson]"></asp:SqlDataSource>
    &nbsp; &nbsp; &nbsp;

<br />

</div>

</form>

</body>

</html>

 

 

SLogix Student Projects


⇓Student Projects⇓
⇑Student Projects⇑
bottom