Webboy2008
asked on
ascx asp.net c#
I have two ascx file. called primary address, mailing address.
in the maling address ascx, i have a check box called same as primary address.
If it is checked, the primary address will be copied and shown in the mailing address.
how can I do it in two ascx file?
500 points if you have completed working codes.
thanks
in the maling address ascx, i have a check box called same as primary address.
If it is checked, the primary address will be copied and shown in the mailing address.
how can I do it in two ascx file?
500 points if you have completed working codes.
thanks
Here is the primary address control code-behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public delegate void SameAddressChecked(object sender, EventArgs e);
public partial class primaddress : System.Web.UI.UserControl
{
public event SameAddressChecked SameAddressEvent;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if(CheckBox1.Checked)
{
if(SameAddressEvent != null)
{
SameAddressEvent(this.PrimAddy.Text, null);
}
}
}
}
}
Here is the secondary address control markup:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="secaddress.ascx.cs" Inherits="WebApplication1.secaddress" %>
Sec Address: <asp:TextBox ID="SecAddy" runat="server"></asp:TextBox>
Here is the secondary address control code-behind:
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 secaddress : System.Web.UI.UserControl
{
public string SetSecAddress
{
set { SecAddy.Text = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
Here is the Default.aspx markup:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<%@ Register src="primaddress.ascx" tagname="primaddress" tagprefix="uc1" %>
<%@ Register src="secaddress.ascx" tagname="secaddress" tagprefix="uc2" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="ContentPlaceholder2">
<uc1:primaddress ID="primaddress1" runat="server" />
<br />
<br />
<uc2:secaddress ID="secaddress1" runat="server" />
</asp:Content>
Here is the Default.aspx code-behind:
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 _Default : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
primaddress1.SameAddressEvent += new SameAddressChecked(primaddress1_SameAddressEvent);
}
void primaddress1_SameAddressEvent(object sender, EventArgs e)
{
secaddress1.SetSecAddress = sender as string;
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
Here is the master page markup (not really needed, except my new projects default to using one):
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="WebApplication1.SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form runat="server">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
Master page code-behind (again, of no real consequence):
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 SiteMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hello...the checkbox should be in mailing address ascx. not primary. please have one completed codes in a file / message attached.
thanks
thanks
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
Open in new window