Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1938
  • Last Modified:

Billing Address Same as Shipping Address checkbox.

I am working with a .net application.  I have a user login/order form created using the wizard controler.  I want to create a check box to import the data from step two into text fields in step 3 saying "check if same as billing address".  I have plenty of concrete examples using javascript, however they are all based around an html form format.  Can someone help me make this work in the world of asp .net?

I'm a total newbie when it comes to .net

Thanks in advance for the help!
FDM

I recieved this expert response, however can't get anymore detail from him.  Can anyone else please elaborate on this.

In asp.net you could achieve by having the shipping value in a session. Use a StringBuilder to have the whole Shipping address with a delimiter for each value and store it in a session variable, then check a condidtion for checkbox "checked" and proceed by assigning the session values for billing as well.
0
FDMilwaukee
Asked:
FDMilwaukee
  • 7
  • 6
  • 2
1 Solution
 
himanshutCommented:
Use a Textbox say TextBox1 and another Text Box say TextBox2.

Place the checkbox where ever you want to place in the Form:

On double clicking the check box you'll see the Sub and code the following into the body:


    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        TextBox2.Text = TextBox1.Text   //  <------ this will copy the value of textbox1 into textbox2 when the checkbox is checked
    End Sub
0
 
FDMilwaukeeAuthor Commented:
except I have 5 different text boxs that need to be controled by the one checkbox
0
 
himanshutCommented:
So you would have 10 textboxes in total, isnt it?
5 for billing and 5 for shipping

so say txtbox1,txtbox2,txtbox3,txtbox4,txtbox5 are for billing and txtbox6,txtbox7,txtbox8,txtbox9,txtbox10 for shipping.

Now in the sub where txtbox1 of billign represents Name and txtbox6 in shipping represents Name as well... and so on....


  Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        txtbox6.Text = txtbox1.Text   //  <------ this will copy the value of NAME textbox1 into textbox2 when the checkbox is checked

txtbox7.Text = txtbox2.Text
|
|
|
and so on...
    End Sub


Hope you got that?
Cheers!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
FDMilwaukeeAuthor Commented:
Thank you so much.  I almost have it.  I apologize for my ignorance.  

The only problem I am having now is that when I uncheck the box the information does not disappear.  I'm assuming I need to include some kind of "if" statement in the vb file, but I just can't get there.

Again I appreciate the help.

0
 
waltersnowslinarnoldCommented:
Try the following code, it will do..

StringBuilder sShippingAddress = new StringBuilder();
sShippingAddress.AppendLine(FirstNameTextBox.Text + " " + LastNameTextBox.Text);
sShippingAddress.AppendLine(Address1TextBox.Text);
sShippingAddress.AppendLine(CityTextBox1.Text);
sShippingAddress.AppendLine(StateTextBox1.Text);
sShippingAddress.AppendLine(ZipCodeTextBox1.Text);

Session["ShippingAddress"] = sShippingAddress.ToString();

Then,

if (Shiptodifferentaddresscheckbox.Checked == true)
        {
            Session["ShippingAddress"] = Session["ShippingAddress"].ToString().Replace("\r\n", "\n");
            string[] sShipping = Session["ShippingAddress"].ToString().Split('\n');
            NameTextBox.Text = sShipping[0];
            AddressTextBox.Text = sShipping[1];
            CityTextBox.Text = sShipping[2];
            StateTextBox.Text = sShipping[3];
            ZipCodeTextBox.Text = sShipping[4];
        }
0
 
waltersnowslinarnoldCommented:
For you last need, enable AutoPostBack="True" for the Checkox. and write in the OnCheckedChanged event as follows.,

protected void Shiptodifferentaddresscheckbox_CheckedChanged(object sender, EventArgs e)
{
        //ClearAllTextBox value and the Session value.
}
0
 
FDMilwaukeeAuthor Commented:
waltersnowsli...

Is this vb or c#  I am having trouble to get that code to work?

Thank you
0
 
waltersnowslinarnoldCommented:
Oops, I gave C#, better put that in a converter.

use the following link to convert by each function

http://www.developerfusion.com/tools/convert/csharp-to-vb/
0
 
waltersnowslinarnoldCommented:
Here i have given you the vb code.. use the following..

    Dim sShippingAddress As New StringBuilder()
    sShippingAddress.AppendLine((FirstNameTextBox.Text & " ") + LastNameTextBox.Text)
    sShippingAddress.AppendLine(Address1TextBox.Text)
    sShippingAddress.AppendLine(CityTextBox1.Text)
    sShippingAddress.AppendLine(StateTextBox1.Text)
    sShippingAddress.AppendLine(ZipCodeTextBox1.Text)

Session("ShippingAddress") = sShippingAddress.ToString()



    If Shiptodifferentaddresscheckbox.Checked = True Then
        Session("ShippingAddress") = Session("ShippingAddress").ToString().Replace(vbCr & vbLf, vbLf)
        Dim sShipping As String() = Session("ShippingAddress").ToString().Split(ControlChars.Lf)
        NameTextBox.Text = sShipping(0)
        AddressTextBox.Text = sShipping(1)
        CityTextBox.Text = sShipping(2)
        StateTextBox.Text = sShipping(3)
        ZipCodeTextBox.Text = sShipping(4)
    End If




0
 
FDMilwaukeeAuthor Commented:
I am still unable to get that code to work
any other suggestions
???
0
 
waltersnowslinarnoldCommented:
Did you notice that the TextBox's for Address, City, State Zipcode are different in the above given code. Place the code where required, not just put one below the other.

Can you just give your code sample.
0
 
FDMilwaukeeAuthor Commented:
I did notice that and change it accordingly.  I'm sure I am missing something obvious, but like I said my asp .net/ vb experience is so incredibly limited.

Attached is a screenshot of the code

Thanks a lot for the help
FDM
Untitled-picture.png
0
 
waltersnowslinarnoldCommented:
I believe you have done mistake in placing the code in the right place, Logic problem, u better post this page code, I 'll try to clear the hurdle..
0
 
FDMilwaukeeAuthor Commented:
Thanks for the help.  I used this code, with some additional steps to clear on uncheck.  I really appreciate the help!
0
 
FDMilwaukeeAuthor Commented:
Waltersnow...

Thanks for the help, but I found another solution.  I do have one other question pending, another problem with the same page if you wouldn't mind taking a look at that one.

It is a problem with the wizard control steps.
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Controls/Q_24988650.html#a26082109

Thank you for your help
FDM
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 7
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now