Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8524543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:43:01+00:00 2026-06-11T07:43:01+00:00

I am new to RAZOR, I want to trigger an event when a user

  • 0

I am new to RAZOR, I want to trigger an event when a user clicks on the RadioButton.

Ideally, it should dynamically show the selected value after a user clicked a RadioButton.

Questions:

  1. How to get the selected value

  2. How to trigger an event when a user clicked a RadioButton.

    @{
        Layout = "~/_SiteLayout.cshtml";
        Page.Title = "Contact";
     }
    
    <div>
      <table>
        <tr>
          <td>
             @Html.RadioButton("Gender", "Male", true) Male
          </td>
          <td>
             @Html.RadioButton("Gender", "Female", false) Female
          </td>
        </tr>
     </table>
          @Html.Label(Request["Gender"] == null ? "No Selection" : Request["Gender"])
    

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:43:03+00:00Added an answer on June 11, 2026 at 7:43 am

    You can not do it with Razor, What you can do is to Create Radio Button Like this and Trigger any Action using Jquery.

    <input type="radio" name="sex" value="male" /> Male <br />
    <input type="radio" name="sex" value="female" /> Female
    

    You could add script (assuming you can use jQuery) on the page like:

    <script type="text/javascript">
    $(function () {
        $(':radio[name="sex"]').change(function () {
            $.ajax({
                url: 'sex',
                type: 'POST',
                data: { sex: $('radio[name="sex"]').val() },
                success: function (xhr_data) {
                    alert(xhr_data.someValue);
                }
            });
        });
    });
    

    Assuming you have an action method in the same controller as the one that generated your view:

    public class YourController : Controller
    {
       public ActionResult sex(string sex)
       {
          // do something awesome
          return Json(new { someValue = "testing!" });
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to RAZOR and now I need to trigger an event when
I am new to MVC 3, razor view engine. I want to set the
I am new to MVC Razor and I have this problem Ex: I want
I want my razor view to look something like this @Ajax.ActionLink(A, Buy, new AjaxOptions()
I want to process user privileges (edit , read,new) in my website , I
I have used this custom Helper in My Razor View. @Html.Link(OpenewWindow, Constants.Value, new {
I am a bit new to razor. So for the below, it's showing model.CarModelName
New to MVC3 Razor - linq to sql having spent some time trying to
I'm a new bie with MVC3 razor. Can anyone please help me why I
I am new in MS MVC3.I am using C# with razor view engine in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.