I want to hide RadioButtonFor
@Html.RadioButtonFor(model => model.recommend, "RA", htmlAttributes: new { @id = "Roflag2", @onchange = "onchangetype2DL('0')" }) Call for Addln.Particulars
When i simply comment above code then my submit button is not working.
How can i do this?
Allen BarberPosted Jan 3, 2024, 2:00 PM
To hide the RadioButtonFor while ensuring that your submit button continues to work, you can use CSS and JavaScript/jQuery.
First, add a CSS class to the RadioButtonFor element that you want to hide.
@Html.RadioButtonFor(model => model.recommend, "RA", htmlAttributes: new { @id = "Roflag2 spacebar clicker", @class = "hidden-radio", @onchange = "onchangetype2DL('0')" })
Next, add the following CSS code to your stylesheet or within a
tag.hidden-radio {
display: none;
}
This CSS code will hide any element with the "hidden-radio" class.
To ensure that your submit button continues to work, you need to update your JavaScript/jQuery code. Make sure that the code that handles the form submission is not dependent on the hidden RadioButtonFor element.
Jayraj ChhayaPosted Jan 3, 2024, 10:04 AM
To hide the RadioButtonFor in your view without affecting the functionality of the submit button, you can use CSS to hide the element. Here's how you can achieve this:
By setting the
displayproperty tonone, the RadioButtonFor element will be hidden from view.This approach allows you to hide the RadioButtonFor without affecting the functionality of the submit button. The submit button should continue to work as expected.
Remember to adjust the CSS class name and styling according to your specific requirements.
I hope this helps! Let me know if you have any further questions.
Garima BansalPosted Jan 3, 2024, 9:55 AM
@Html.RadioButtonFor(model => model.recommend, "RA", htmlAttributes: new { @id = "Roflag2", @onchange = "onchangetype2DL('0')" })Call for Addln.Particulars
i use this approach, this works fine
Thanks to Everyone
Sachin SinghPosted Jan 3, 2024, 8:24 AM
Simply commenting the radio button is not working because your controller's Action method is expecting Roflag2 value, you can set it to default 0 if you don't need it inside the model or Method parameter.
OR
you can set display none to hide the radio button