Jump to content

radiobutton onclick


Emwat Oon
 Share

Recommended Posts

Is there a way to tie a radiobutton into a function? Like onClick?

 

I've looked on msdn, but the closest I found is OnCheckedChanged and that isn't working for me. This is what I've tried.

    <asp:RadioButton ID="radSpecifyOther" runat="server" GroupName="specify" Text="Other" OnCheckedChanged="radEnableOther" EnableViewState="true"/>    protected void radEnableOther(object sender, EventArgs e)    {        if (radSpecifyOther.Checked)        txtEnableSpecify.Enabled = true;        else txtEnableSpecify.Enabled = false;    }
Edited by Emwat Oon
Link to comment
Share on other sites

  • 5 years later...

Yes you can use onclick event as

 <asp:RadioButton ID="chkNo" Text="No" runat="server" onclick="fn()" />

you can add your own function.

After this you can use the JavaScript to define function.

<script type="text/javascript">
        function fn() {
            alert("I have clicked no button");
        }
    </script>

i hope you will understand.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...