DialogRestoreEventArgs.cs
----------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
public class DialogRestoreEventArgs
{
Dictionary<string, string> _paramValues = null;
public DialogRestoreEventArgs()
{
_paramValues = new Dictionary<string, string>();
}
public Dictionary<string, string> ArgumentValues
{
get
{
return _paramValues;
}
set
{
_paramValues = value;
}
}
public void AddParam(string key, string value)
{
if (_paramValues == null)
_paramValues = new Dictionary<string, string>();
if (_paramValues.ContainsKey(key))
throw new DuplicateNameException(string.Format("Parameter {0} already exist in argument collection", key));
_paramValues.Add(key, value);
}
public string GetParam(string key)
{
if (_paramValues == null)
return string.Empty;
if (!_paramValues.ContainsKey(key))
throw new ArgumentException(string.Format("Parameter key {0} not found in collection", key));
return _paramValues[key];
}
}
Email.ascx
--------------
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Email.ascx.cs" Inherits="MyCollections.UserControls_Email" %>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
Email.ascx.cs
-----------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MyCollections
{
public partial class UserControls_Email : System.Web.UI.UserControl
{
public delegate void DialogRestoreEventHandler(object senders, DialogRestoreEventArgs e);
public event DialogRestoreEventHandler RestoreModalDialog;
protected void Button1_Click(object sender, EventArgs e)
{
if (RestoreModalDialog != null)
{
DialogRestoreEventArgs evnts = new DialogRestoreEventArgs();
RestoreModalDialog(sender, evnts);
}
}
}
}
Default.aspx
--------------
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Src="~/UserControls/Email.ascx" TagName="CustomerEmail" TagPrefix="CustEmail" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Button ID="btn1" runat="server" Text="Submit" />
<div id="myMailDiv" style="width: 50%; height: 50%;">
<asp:Button runat="server" ID="btnSendMail" Style="display: none" />
<asp:ModalPopupExtender ID="ModelpopEmail" runat="server" TargetControlID="btn1"
PopupControlID="panelSendEmail" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
<asp:Panel ID="panelSendEmail" runat="server" BackColor="white" BorderColor="Black">
<div id="emailDiv" style="border: 1px solid #666666; padding: 5px;">
<div id="customerinfogrid" style="width: 97%;">
<div id="gridimg">
<%-- <img src="Images/emailthisproperty.png">--%>
</div>
<div id="gridtxt">
Customer Email
</div>
</div>
<%-- <asp:Button ID="Button1" runat="server" Text="Cancel" OnClick="btncancel_Click" />--%>
<div>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<CustEmail:CustomerEmail ID="CustomerEmail1" runat="server" />
</div>
<asp:Button ID="btncancel" runat="server" Text="Cancel" OnClick="btncancel_Click" />
<asp:Button ID="btnOpen" runat="server" Text="Open" OnClick="btnOpen_Click" />
</div>
</asp:Panel>
</div>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyCollections;
public partial class _Default : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
CustomerEmail1.RestoreModalDialog += new UserControls_Email.DialogRestoreEventHandler(CustomerEmail1_RestoreModalDialog);
}
void CustomerEmail1_RestoreModalDialog(object senders, DialogRestoreEventArgs e)
{
ModelpopEmail.Show();
}
protected void Button_Click(object sender, EventArgs e)
{
ModelpopEmail.Show();
}
protected void Page_Load(object sender,EventArgs e)
{
// base.OnInit(e);
// btn1.Click += new EventHandler(btnShowText_Click);
}
void btnShowText_Click(object senders, EventArgs e)
{
// ModelpopEmail.Show();
}
protected void btncancel_Click(object senders, EventArgs e)
{
ModelpopEmail.Hide();
}
//btnOpen_Click
protected void btnOpen_Click(object senders, EventArgs e)
{
ModelpopEmail.Show();
}
static void Button1_Click(object o, EventArgs e)
{
//Console.WriteLine("Event being called.");
//Console.ReadLine();
}
protected static void OnMyTestEvent(object sender, EventArgs e)
{
}
}
0 comments:
Post a Comment