Link to home
Start Free TrialLog in
Avatar of Collindsouza
CollindsouzaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

HTML Radio Button setting Onclick event

I have a repeater control with a HTML radio button in it..

<input id="rbSelected" type="radio" value='<%# DataBinder.Eval(Container.DataItem,"ContactID") %>' runat="server" />

I need to add a onclick event so that i can handle this event code behind..

i tried adding something like this..


<input id="rbSelected" type="radio" value='<%# DataBinder.Eval(Container.DataItem,"ContactID") %>' runat="server" onclick="rbSelected_Click" />

and in code behind i tried to handle this event..

protected void rbSelected_Click(object sender, EventArgs e)
    {
       
    }
but it doesnt work..

If there is'nt any onclick event.. is there any other way i could handle this  code behind.. meaning when the user clicks on a radio button.. then capture that event code behind..


Please help !!!
Avatar of Justin_W
Justin_W

1. Set the radiobuttons AutoPostback attribute to True.
2. Create an OnSelectionChanged event handler for the button. (e.g. Double-clicking the radiobutton in VS.NET should add an empty handler for you to customize.
Avatar of Collindsouza

ASKER

Hi Justin,

Since this is a HTML Radio Button... there is no AutoPostback attribute :((
ASKER CERTIFIED SOLUTION
Avatar of Justin_W
Justin_W

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi justin,

Many Thanks !!! yes you are right.. the path that i'm taking is getting quite complicated.. Writing a javascript routine to cause a page post back seems the only way out..

However i'm binning my entire approach and i will re-do it using gridview.. It seems to be a more sensible solution to my problem..

Thanks for your help..

Collin
You're welcome!