Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
I have a page that in the right side I have billing address (that is user control) and on the left side I have another user control that is shipping address. I have a checkbox in the page that by checking this checkbox I would like to fill out the shipping address with billing address. I usefully do this with JavaScript function but as long as here these 2 set of textboxes are user control I dont know how I can do this.
Posted

make chechbox=>Properties=>autopostback=true,
in check event
if(chechbox.checked)
{
textbox2.Text=textbox1.Text;
}
else
textbox2.Text="";

//or
if(chechbox.checked)
{
foreach (Control c in form1.Controls)
        {
            if (c.GetType().Name.ToLower() == "webusercontrol_ascx")
            {
                UserControl uc = (UserControl)c;
                TextBox txt = (TextBox)uc.FindControl("txtShiptoName");
                TextBox txt2 = (TextBox)uc.FindControl("txtShiptoName2");
                txt2.Text = txt.Text;
            }
        }
}
else
txt2.Text="";
 
Share this answer
 
v2
Comments
snehaww 7-Mar-12 10:12am    
Thanks.
C#
protected void chkCopy_CheckedChanged(object sender, EventArgs e)
{
     if(txtBilling.Tex!=string.Empty)
     {
       txtShipping.Text=txtBilling.Text;
     }
     else
     {
       lblMessage.Tex="Billing Address is Null";
     }

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900