connectseekers.com

Friday, 10 October 2014

Execute Or Open ModalPopupExtender as MessageBox From Code Behind Using C#.Net In Asp.Net

10/10/2014 - By Pranav Singh 0

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.


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.



About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com
Email Id : contact@aspdotnet-pools.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top