I make a site, and on the whole site I do not really agree with how I get user input for postback. For example, say in a button event, which takes two lines extracted from text fields and combines them and displays the sum of the line in the label:
protected void btnCalculate_Click(object sender, EventArgs e)
{
string text1 = textBox1.Text;
string text2 = Request["textBox2"];
lblSum.Text = text1+text2;
}
I assume that you will want to use Request [""] if the data was sent to a new page, but for this situation one of the methods is preferable to the other, and why?
source
share