HTML Helper Class in
Razor View Engine in MVC
(Radio Button, Password, TextArea)
In previous article I discussed about the HTML Helper class and we created some control
using this class. In this article I am continuing this topic and will discuss
about the others controls and continue with the previous example which I used
in my last article.
Note:-Before
reading this article kindly goes through the previous article.
RadioButton
This HTML
Helper method is used to create Radio Button. This method returns radio button
input element. In this method we pass id and name to the radio button method as
a first parameter. In second value we pass the value which will be accessed
when form submitted.
For example:-
@Html.RadioButton("rgender","Male")
In this example rgender is id and name for this control
and Male is the value which accessed on form submitted.
If you want to by default select any value then you can
also pass third parameter as true which represent the value as selected.
For
example:-
@Html.RadioButton("rgender","Male",true)
Password
This HTML Helper method is used to create TextBox having
password type. In this method we pass the id and name to this control.
For example:-
@Html.Password("pass")
In this example pass is id and name in this example.