[英]How to pass radio button list parameters into C# from HTML
我有一个HTML代码:
<form method="POST" action="FeedBack.aspx.cs"> <div class="container"> <h2>FeedBack Area</h2> <br /> <h4>Comfort</h4> <br /> <form role="form"> <label class="radio-inline" name="radio1"> <input type="radio" value="1" name="optradio1">Bad </label> <label class="radio-inline"> <input type="radio" value="2" name="optradio2">Good </label> <label class="radio-inline"> <input type="radio" value="3" name="optradio3">Excellent </label> <br /> </form> </form>
和一个C#代码:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string r1, r2, r3, r4;
r1=string.Format("{0}", Request.Form["radio1"]);
r2=string.Format("{0}", Request.Form["radio2"]);
r3=string.Format("{0}", Request.Form["radio3"]);
r4=string.Format("{0}", Request.Form["radio4"]);
FeedBackService.InsertIntoReviewes(r1,r2,r3,r4);
MessageBoxShow(Page,"FeedBack Sent.");
}
}
我希望当您单击单选按钮值时,该值将传递到C#中并进入函数:InsertIntoReviews,将r1,r2,r3,r4值放入Access数据集中。
请注意,我已经只附加了四分之一的代码,因为它太长了。 顺便说一句,我关闭了第一个表单标签,因为它只是代码的一部分(它在完整代码的结尾处关闭了)。
非常感谢你。 :)
也许可以帮助您。
$('input [type = radio]')。change(function(){$ .ajax({url:'controller / InsertIntoReviewes',data:{radios:$(“ formName”)。serializeObject()},成功:函数(结果){}});});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.