We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get the value?

Thread ID:

Created:

Updated:

Platform:

Replies:

150762 Jan 18,2020 02:50 PM UTC Feb 5,2020 05:37 AM UTC Blazor 5
loading
Tags: Radio Button
Alex Whittle
Asked On January 18, 2020 02:50 PM UTC

When selecting a radio button I want to retrieve the value associated with it- - is this possible?

Saranya Dhayalan [Syncfusion]
Replied On January 20, 2020 07:35 AM UTC

Hi Alex,  
  
Thanks for contacting Syncfusion support.  
  
We have checked your requirement and we have an API ‘getSelectedValue’ which is used for getting the selected value from the group of radio buttons. You can use this method in any one of the radio button instances in the group. Please find the below code snippet: 
 
@using Syncfusion.EJ2.Blazor.Buttons 
 
<EjsRadioButton @ref="radiobtn" Label="Option 1" Name="options" Value="option1"></EjsRadioButton> 
<EjsRadioButton Label="Option 2" Name="options" Value="option2" Checked="true"></EjsRadioButton> 
 
<button @onclick="@getSelectedValue">Get Value</button> 
 
@code{ 
    EjsRadioButton radiobtn; 
 
    public async void getSelectedValue() 
    { 
        string obj = await radiobtn.GetSelectedValue(); 
    } 
} 
 
 
 
Please find the below API documentation link: 
 
Could you please check the above code snippet and get back to us if you need further assistance on this?  
 
Regards,  
Saranya D 
 


Alex
Replied On February 3, 2020 08:33 AM UTC

Hi, thanks for the response.

How do we do this without using a button?  I want to be able to get the value after selecting a radio button not by then pressing a button.

Saranya Dhayalan [Syncfusion]
Replied On February 4, 2020 05:17 AM UTC

Hi Alex 
 
Thanks for the update 
 
Query: How do we do this without using a button?  I want to be able to get the value after selecting a radio button not by then pressing a button. 
 
We have checked your reported query, we can get the value after selection radiobutton in OnChange event. Please find the below code snippet: 
 
@using Syncfusion.EJ2.Blazor.Buttons 
 
<EjsRadioButton @ref="radiobtn1" Label="Option 1" Name="options" Value="option1" OnChange="onChange"> 
</EjsRadioButton> 
<EjsRadioButton @ref="radiobtn2" Label="Option 2" Name="options" Value="option2" Checked="true" OnChange="onChange1"></EjsRadioButton> 
 
@code{ 
    EjsRadioButton radiobtn1; 
 
    EjsRadioButton radiobtn2; 
 
    public async void onChange() 
    { 
        string obj = await radiobtn1.GetSelectedValue(); 
    } 
     public async void onChange1() 
    { 
        string obj1 = await radiobtn2.GetSelectedValue(); 
    } 
} 
 
 
Please find the below API doc link 
 
 
Could you please check the above code snippet and get back to us if you need further assistance on this? 
 
Regards, 
Saranya D 


Alex
Replied On February 4, 2020 02:02 PM UTC

Thanks for the response.

Can we have a single method and then detect the value of the radio button that fired the method off?

Saranya Dhayalan [Syncfusion]
Replied On February 5, 2020 05:37 AM UTC

Hi Alex, 
 
Good day to you 
 
Query: Can we have a single method and then detect the value of the radio button that fired the method off? 
 
We have checked your reported scenario, If you want to use a single method in the radio button group, you need to bind the change event to each radio button. Please find the below code snippet 
 
@using Syncfusion.EJ2.Blazor.Buttons 
 
<EjsRadioButton @ref="radiobtn" Label="Option 1" Name="options" Value="option1" OnChange="onChange"> 
</EjsRadioButton> 
<EjsRadioButton Label="Option 2" Name="options" Value="option2"  OnChange="onChange"></EjsRadioButton> 
 
@code{ 
    EjsRadioButton radiobtn; 
 
    public async void onChange() 
    { 
        string obj = await radiobtn.GetSelectedValue(); 
    } 
} 
 
 
 
Could you please check the above code snippet and get back to us if you need further assistance on this? 
 
Regards, 
Saranya D 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon