Passing value from Javascript function to CS file


I am setting a value of a radio button in a javascript function.

Now, to save this value of radio button in database, I have code which is in the aspx.cs file.

How do I pass this value of radio button to aspx.cs file?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Amandeep Singh BhullarCommented:
Any value that is set through a JavaScript is not readable in .cs fle
But there is one trick

Place a hidden textbox on page.
Make it hidden with style tag.

Before posting a page back, set the value of textbox as of selected value of radio button.
Value of text box is readable at server side.
Use textbox as

<input type="text" runat="server" id="txthidden" style="display:none" />

Hope this will help u

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Om PrakashCommented:
Radio button is server control or HTML controls?
If it is codebehind, then you can directly access from id, in case of HTML control:

(1) Edit the HTML code to include the attribute runat="server" in the
opening tag of the HTML control. For example for a table it might be:
<TABLE id="Table1" ...(other attributes) ... runat="server">

(2) Then you need to include the namespace "System.Web.UI.HtmlControls"
in the code behind (e.g. in VB the directive Imports
use hidden controls.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.