Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HTML Radio Button setting Onclick event

Posted on 2006-07-20
5
Medium Priority
?
2,755 Views
Last Modified: 2008-02-01
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 !!!
0
Comment
Question by:Collindsouza
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 24

Expert Comment

by:Justin_W
ID: 17147734
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.
0
 
LVL 5

Author Comment

by:Collindsouza
ID: 17147841
Hi Justin,

Since this is a HTML Radio Button... there is no AutoPostback attribute :((
0
 
LVL 24

Accepted Solution

by:
Justin_W earned 2000 total points
ID: 17147961
Then you would have to use client-side jscript events to cause a PostBack, and then manually determine in your codebehind whether your jscript caused the PostBack, and react accordingly. You can't directly hook a server-side handler to a client-side event.

Either use a RadioButton web control, or look here (http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/input_radio.asp) and review the available client-side events that you can use with the HtmlInputRadioButton. Unless you are very comfortable with the ASP.NET page lifecycle and also jscript, I would highly recommend you use a RadioButton web control instead.
0
 
LVL 5

Author Comment

by:Collindsouza
ID: 17148035
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
0
 
LVL 24

Expert Comment

by:Justin_W
ID: 17148108
You're welcome!
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question