1

I'm trying to put the ship to info into the bill to info text boxes. When the check box is checked the bill to info text boxes need to be populated with the same values from ship to info text boxes. The code that I have works when I click the send button the values are displayed on a separate page and if the check box is checked the ship to and bill to are the same. But on the form when I click the check box the blank bill to fields are not populated with the same data, the text boxes stay empty even with the declared values.

    protected void CbxShipto_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox CbxShipto1 = (CheckBox)this.FindControl("CbxShipto");

        if (CbxShipto1.Checked)
        {
            txtFirstName2.Text = TxtFirstName.Text;
            txtLastName2.Text = TxtLastName.Text;
            ddlState2.Text = ddlState.Text;
            txtStreet2.Text = TxtStreet.Text;
            txtCity2.Text = txtCity.Text;
            txtzip2.Text = txtZip.Text;
        }
    } 
Ivan_Stepul
  • 229
  • 1
  • 2
  • 8
  • Can you debug and see if CheckedChanged is fired at all? You can take a look at some of the answers here if it could help you: http://stackoverflow.com/questions/15772642/why-does-checkchanged-event-does-not-fire-on-uncheck-of-checkbox-in-asp-net – Tyress Nov 26 '14 at 02:48
  • Why don't you just do this on the client? There isn't a reason to involve the server if the client already has the info. – mason Nov 26 '14 at 04:26

1 Answers1

1

Make sure that in the page markup the tag for CbxShipto1 has OnCheckedChanged="CbxShipto_CheckedChanged" and AutoPostBack="true".

Also, you do not need local CheckBox variable and FindControl. You should already have CbxShipto class member that you can use - that is if CbxShipto is not created in code dynamically.

Igor
  • 15,833
  • 1
  • 27
  • 32