This article will show you how you can open a ModalPopupExtender
control after saving the record the display the success message or error
message. So this article will show you to Execute Or Open ModalPopupExtender
From Code Behind Using C#.Net In Asp.Net.
Some of my previous articles are as follows: Display
Validation in ToolTip Using ValidatorCalloutExtender in Asp.Net, AjaxControlToolkit
ModalPopupExtender With AutoCompleteExtender In Asp.Net Using C#.Net, Multiple
controls with the same ID '_header' were found. FindControl requires that controls
have unique IDs. in Asp.net, Ajax
Login Form In Asp.Net Using C#.Net and VB.Net Without PostBack, Example
of Ajax Control Toolkit ModalPopupExtender In Asp.Net.
So for this article first we will create a new asp.net application and add the below code in your .aspx page.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2"
%>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
TagPrefix="asp"
%>
<!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>Execute
Or Open ModalPopupExtender From Code Behind Using C#.Net In Asp.Net
</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
CancelControlID="btnclose"
DropShadow="false" PopupControlID="pnlmessage" TargetControlID="hiddata">
</asp:ModalPopupExtender>
<asp:Panel ID="pnlmessage" runat="server" BorderColor="Black" BorderStyle="Outset"
BorderWidth="1" BackColor="Gray" Width="211px" Height="130px">
<table width="210px">
<tr>
<td style="background-color: Black; color: White;">
Success
message
</td>
</tr>
<tr>
<td>
<center>
<h3>
<asp:Label ID="lblWarning"
runat="server">
</asp:Label>
</h3>
<asp:Button ID="btnclose"
runat="server"
Text="Close"
/>
</center>
</td>
</tr>
</table>
<asp:HiddenField ID="hiddata" runat="server" />
</asp:Panel>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Save" />
</form>
</body>
</html>
|
Now add the below code into your .cs page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class WebForm2 : System.Web.UI.Page
{
protected
void Page_Load(object
sender, EventArgs e)
{
}
protected
void Button1_Click(object
sender, EventArgs e)
{
ModalPopupExtender1.Show();
lblWarning.Text = "Data Saved Successfully.";
}
}
}
|
Here I have set the property show() so that it will display the ModalPopupExtender
control, and message in label control. Now check the output.
0 comments:
Please let me know your view