C# get string from textbox
In C#, unlike java we do not have to use any method. TextBox property Text
is used to get or set its text.
Get
string username = txtusername.Text;
string password = txtpassword.Text;
Set
txtusername.Text = "my_username";
txtpassword.Text = "12345";
The TextBox
control has a Text
property that you can use to get (or set) the text of the textbox.
When using MVC, try using ViewBag. The best way to take input from textbox and displaying in View.