This article will show you how you can display confirmation
message with yes, no button in asp.net using Ajax Control Toolkit, confirmbuttonextender and
modalpopupextender. In this I have user C# to display the message after user
click on Yes.
Some of previous articles are as follows: Dragable
ModalPopupExtender In Asp.Net Using AjaxControlToolkit, AjaxControlToolkit
ModalPopupExtender With AutoCompleteExtender In Asp.Net Using C#.Net, Display
Validation in ToolTip Using ValidatorCalloutExtender in Asp.Net, CalendarExtender
Example With Custom Style By Css Uaing Asp.net and Css, TextBoxWatermark
Contol Of AjaxControlToolKit For Displaying Watermark in TextBox In Asp.Net,
How to Use and
Install Ajaxcontroltoolkit in Asp.Net, GridView
With Autocomplete Textbox Using AutoCompleteExtender in Asp.net Using C#.Net,
Execute
Or Open ModalPopupExtender as MessageBox From Code Behind Using C#.Net In
Asp.Net, AjaxControlToolkit
CalendarExtender to Display Calendar in Asp.net on Textbox Click.
So for this article first we will create a new asp.net application and add confirmbuttonextender, modalpopupextender and prepare the div message to display the confirmation message with yes and no button.
So for this article first we will create a new asp.net application and add confirmbuttonextender, modalpopupextender and prepare the div message to display the confirmation message with yes and no button.
So here is article here is the code.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="WebApplication2.WebForm5"
%>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
TagPrefix="cc1"
%>
<!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>Confirmation
Message With Yes, No Button In Asp.Net Using ConfirmButtonExtender and
ModalPopupExtender</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"
TargetControlID="Button1"
ConfirmText="Are you sure you want to submit data?" DisplayModalPopupID="ModalPopupExtender1">
</cc1:ConfirmButtonExtender>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="Button1"
PopupControlID="divMessage" CancelControlID="btnNo">
</cc1:ModalPopupExtender>
</div>
<div id="divMessage" runat="server" style="border: 1px solid black;">
<table style="width: 300px; height: 100px; background-color: White; border: 1 solid black;
border: 1; border-collapse: collapse">
<tr>
<th style="background-color: Gray; color: White; height: 30px;">
Confirm Message
</th>
</tr>
<tr>
<td>
Are you sure do you want
to submit form?
</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="btnYes" runat="server" Text="Yes" OnClick="btnYes_Click" />
<asp:Button ID="btnNo" runat="server" Text="No" />
</td>
</tr>
</table>
</div>
<asp:Button ID="Button1" runat="server" Text="Show Confirmation Message" /><br />
Current Date Time :
<asp:Label ID="lblMessage" runat="server" Style="color: #FF0000" Text=""></asp:Label>
</form>
</body>
</html>
|
Now on yes button click add the below code to display the
message.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public partial class WebForm5 : System.Web.UI.Page
{
protected
void Page_Load(object
sender, EventArgs e)
{
}
protected
void btnYes_Click(object
sender, EventArgs e)
{
lblMessage.Text = DateTime.Now.ToString();
}
}
}
|
In above code as user click on yes above click event will
get called and display on the label control. Now we have done run the
application to check the output.
DOWNLOAD
0 comments:
Please let me know your view