You need to add the code to the button event handler:
public void Button1_Click(Object sender, EventArgs e) { TextBox1.Text = "1"; }
To display string
"1" in the text box.
You can also have several text fields on a web page and use:
public void Button1_Click(Object sender, EventArgs e) { string input1 = txtInput.Text; string input2 = txtInput2.Text; int userInput; int userInput2; int result; Int32.TryParse(input1, out userInput); Int32.TryParse(input2, out userInput2); result = userInput + userInput2; txtAnswer.Text = "The answer is: " result.ToString(); }
I included the TryParse
example, which demonstrates a successful conversion from integers to numbers.
source share