I've found out that when its converted to a .net control instead of checked="checked" (as it would be usually) it is just Checked, so I changed that but on inspecting the DOM in multiple browsers, none of my radio buttons are being checked :-(

Are there any other ways I can use jQuery to check a radio button that has runat="server"?

Adding a runat="server" shouldn't affect your code. Did you also add this attribute to the 'SomethingElse' element, as it would probably change the rendered ID?
–
PaddyAug 10 '10 at 14:40

yea I didn't think it'd affect it either, I haven't added it to the 'SomethingElse', which is an anchor tag, if that helps?
–
Wayne AustinAug 10 '10 at 14:45

1

@ wyane i just tested with the attribute runat="server" and it seems to work fine...looks like a conflict,are you using any other javascript framework in the same page?
–
manraj82Aug 10 '10 at 15:27

@manraj82 awesome, just the fact that u have got it working is great news! though i'm not using any other js frameworks, I'ma just start a process of elimination on this, I'll let ya'll know how it goes. Thank for you help!
–
Wayne AustinAug 10 '10 at 15:32

8 Answers
8

I think that Your problem is that the id of the input is no longer sector1Radio but rather ctl00_sector1Radio or something similar. This happens if Your input control is inside e.g. a ContentPlaceHolder control (when using master pages).

Can You check the generated HTML code (in the browser) to verify if this is the case? What is the id of the input control?

Best thing is to view the generated html code and see what id is giving you, then you can use the appropriate jquery selector, because the generated id could have different extensions depends whether you use master pages, etc.

If you are using a MasterPage or are creating the controls dynamically then it is probable that the control ID's are being renamed #SomethingElse becomes #MainContent_SomethingElse.

The easiest way to check this is to use the WebDeveloper plugin for Firefox or Chrome.
Go to Information -> Display Element Information and then select the object in question. It will give you it's ID, class, as well as ancestor and children information.
Check to see if the ID is being changed dynamically by the .NET.

If that's the case:

To prevent this, in the server side code you can use the following attribute to create static ID's

Two things here: finding the control and executing the check. In ASP.NET, your control's actual ID and name will end up getting changed based on the runat="server" containers in which it appears, even if those containers have no Ids.

Rendered ASP.NET controls always end with the same name as you started with, so a tag like:

The id of the input tag must be correctly referenced by the label's for attribute. If the webpage is inside a master page then the id of the input tag will be modified to something like ctl00_Something_radio1, and suddenly the label's for attribute no longer references the input tag. Beware of this in ASP.NET!