简体   繁体   中英

How to pass radio button list parameters into C# from HTML

I have a HTML code of :

  <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> 

And a C# code :

 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.");
    }
}

And I want that when you hit a radio button value the value will pass into C# and will get into the function : InsertIntoReviews that put the r1,r2,r3,r4 values into Access dataset.

Note that Ive attached only quarter of the code since it is too long. Btw I closed the first form tag because it is only a part of the code (it closed at the end of the full code).

Thank you very much. :)

Maybe help you.

$('input[type=radio]').change( function() { $.ajax({ url: 'controller/InsertIntoReviewes', data: { radios : $("formName").serializeObject() }, success: function(result){ } }); });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM