chokka
asked on
How to invoke the JavaScript function from code behind (c# / controller)?
How to invoke the JavaScript function from code behind (c# / controller)?
In MVC, Controller - I will have to enable or disable the text box in the Controller.
In c#, i will have to fetch the HTML element id.
Then based on the condition result loaded from database, I will have to enable or disable the Textbox element id.
In MVC, Controller - I will have to enable or disable the text box in the Controller.
In c#, i will have to fetch the HTML element id.
Then based on the condition result loaded from database, I will have to enable or disable the Textbox element id.
if ($("input:radio[name='RadioButtonSelection']:checked").length > 0)
{
var isChecked = document.getElementById("RadioButtonSelectionYes").checked;
if (isChecked == true)
{
document.getElementById('ShowTextBox').disabled = false;
} else if (isChecked == false)
{
document.getElementById('ShowTextBox').checked = true;
document.getElementById('ShowTextBox').disabled = true;
}
}
ASKER
Thank you
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
If you have a razor view you can do that with razor.
For instance have a variable in ViewBag in your controller like this:
Open in new window
Then in your view you may have it like this:
Open in new window
Giannis