1

i have designed a Page just like Yahoo Sign Up Page.. i want to do such that when i fill all the required fields of that page, those filled values get displayed on a textbox. i wrote a code i.e:

TextBox9.Text = TextBox1.Text; TextBox9.Text = TextBox2.Text; TextBox9.Text = TextBox3.Text; TextBox9.Text = TextBox4.Text; TextBox9.Text = TextBox5.Text; TextBox9.Text = TextBox6.Text; TextBox9.Text = TextBox7.Text; TextBox9.Text = TextBox8.Text; 

but it is displaying only the value of textbox8 in textbox9..

2 Answers 2

4

In your example, you're just continually re-setting the Text property of TextBox9. I think maybe what you want is something like this:

StringBuilder sb = new StringBuilder(); sb.AppendLine(TextBox1.Text); sb.AppendLine(TextBox2.Text); sb.AppendLine(TextBox3.Text); sb.AppendLine(TextBox4.Text); sb.AppendLine(TextBox5.Text); sb.AppendLine(TextBox6.Text); sb.AppendLine(TextBox7.Text); sb.AppendLine(TextBox8.Text); TextBox9.Text = HttpUtility.HtmlEncode(sb.ToString()); 
Sign up to request clarification or add additional context in comments.

Comments

2

You should concatenate the values:

TextBox9.Text = TextBox1.Text; TextBox9.Text += TextBox2.Text; TextBox9.Text += TextBox3.Text; TextBox9.Text += TextBox4.Text; TextBox9.Text += TextBox5.Text; TextBox9.Text += TextBox6.Text; TextBox9.Text += TextBox7.Text; TextBox9.Text += TextBox8.Text; 

The first row assignes the value of TextBox1 to TextBox9.
The second row ADDS the value of TextBox2 to TextBox9.
The third row ADDS the value of TextBox3 to TextBox9.
etc.

Suggestion:
You should consider using better variable names instead of the default ones.

2 Comments

Abid, you should read up on XSS (cross-site scripting). It's a good thing to know when trying to do things with textbox controls.
@Lareau: Indeed he should but I believe that currently it is WAY beyond his capabilities.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.