If I add this to the ASPX page:
<input id="Text1" type="text" value="Text1Value" />
I would expect to see "Text1" in the list of Request Form keys even WITHOUT setting the runat=Server
property.
? request.Form.AllKeys
I realize that if I do set that propery, then I will have a server-sided HTML control that I can reference using the name "Text1"
, but shouldn't I be able to access the text in the text box using the following VB.NET syntax?
request.Form("Text1")
IMO the main difference is that Textbox is not strongly typed. TextboxFor take a lambda as a parameter that tell the helper the with element of the model to use in a typed view. You can do the same things with both, but you should use typed views and TextboxFor when possible. Save this answer.
The HTML textbox is an input control that allows the user to enter the text input on the web page. The <input type = “text”> is used to create a textbox.
TextBoxFor() The TextBoxFor<TModel, TProperty>() is the generic extension method that creates <input type="text"> control. The first type parameter is for the model class, and second type parameter is for the property.
Because you need to add the name attribute. Try this
<input id="Text1" name="Text1" type="text" value="Text1Value" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With