Li
Delete
Are you sure you want to delete this?
ProgrammingModel
-
Date
-
20211102
-
Target
-
C_032
-
Title
-
Radio Button in mvc get value / What means input attribute name?
-
Contents
-
https://forums.asp.net/t/1924996.aspx?Radio+Button+in+mvc+get+value
HttpPost
public ActionResult YourAction(string YourRadioButton)
{
//Your Action Code Here
}
MVC will automatically post the value of your RadioButton (with the name "YourRadioButton") and map it to the parameter of the same name so that you could easily access it, however if you are not fond of actually including a parameter, you could always access it from the Request.Form object as you might in WebForms as well :
var YourRadioButton = Request.Form["YourRadioButton"];
Using an HTML Helper Method
An HTML Helper method such as Html.RadioButton will function the same exact way as mentioned above :
@Html.RadioButton("YourRadioButton","A")
@Html.RadioButton("YourRadioButton","B")
What means input attribute name?
cn.tanz.co.kr에서 결제방법을 선택할 때 Radio btn이면서 name은 PaymentMethodId로 되어 있는 것을 해석하기 위해서 한 질문이다.
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_name
input type=text id=fname name=fname
input type=text id=lname name=lname
input type=submit value=Submit>
Submitted Form Data
Your input was received as:
fname=Lee&lname=Byungil
The server has processed your input and returned this answer.