Sunday 27 September 2009

How do you add a value from a webform to a variable in C#?

In Visual Studio 2005 :

Create a webform with a text field and change it's name to 'txtID'
Create another text field to show the result of the variable and change its name to 'txtResult'
Add a button and then add this code to it's click event.

String info = txtID.Text;

txtResult.Text = info;

When the button is clicked it will take the text that is in the field and add it to the variable called 'info. It will then display the value of the variable in the txtResult field.

No comments:

Post a Comment