[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

HTML Radio Button setting Onclick event

Posted on 2006-07-20
5
Medium Priority
?
906 Views
Last Modified: 2008-01-09
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
5 Comments
 
LVL 2

Expert Comment

by:M3hcSS
ID: 17147333
Set postback to true in properties.

PostBack=True;
0
 
LVL 2

Expert Comment

by:M3hcSS
ID: 17147340
Sorry, I mean to say...

rbSelected.Autopostback=True;
0
 
LVL 5

Author Comment

by:Collindsouza
ID: 17147430
Hi M3hcSS,

Since this radio button is a HTML Control It doesnt have a property called Autopostback

The reason i'm using a HTML radio button is because i'm trying to store a value for the radio button in it..

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

Accepted Solution

by:
Justin_W earned 2000 total points
ID: 17147988
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.

You should still be able to set the value of a RadioButton web control. Even though it doesn't list value as a server-side property, you can still use it since it is a regular HTML attribute of the input type=radio tag. Or, you could simply set a myvalue=... atribute, and check the value of the control's Attributes["myvalue"] in the codebehind.
0
 
LVL 15

Expert Comment

by:dave4dl
ID: 17148622
<asp:radiobutton runat="server" id="rbSelect"></asp:radiobutton>
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

649 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