开发者

Asp.net Beginner

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 = Text开发者_C百科Box2.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..


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());


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜