CovertCoder
Login
|
Register
Search
Main Navigation
Home
Contact Us
Login
Register
Tools
Code Generator
Knowledge Base
Featured Articles
Adding an AJAX Collapsible Panel
Binding Listbox with XLINQ
Calling Parent Page from Child
Datagrid Sort with LINQ
ListView in UpdatePanel
Programmatically call FancyBox
Tutorials
ASP.Net Tutorials
Add nicEdit to an ASP.Net page
AJAX Tutorials
Convert Web App for MVC Framework
Keep state of Collapsible Panel
Retrieving XML Config file values
Windows phone 7 Styles (Static Resources)
Topic: How to enable a Radio Button Group inside a repeater with JavaScript
Description: This code allows you to treat radio buttons inside a repeater as a group. This is needed because Microsoft's repeater control implements the INamingContainer making each control unique. The GroupName attribute will not work because the unique client naming overrides the use of the GroupName property. The Javascript below basically unchecks the radio buttons that are not selected.
1. On the ItemDataBound event add the follwoing line:
rdoMyBatch.Attributes.Add("onclick", "SetUniqueRadioButton('rptLabels.*rdoMyBatchIdentifier', this)")
2. Add the following JavaScript to your page or inside a Javascript code behind file.
function
SetUniqueRadioButton(nameregex, current)
{
re =
new
RegExp(nameregex);
for
(i = 0; i < document.formss[0].elements.length; i++)
{
elm = document.forms[0].elements[i];
if
(elm.type == 'radio')
{
if
(re.test(elm.name))
{
elm.checked =
false
;
}
}
}
current.checked =
true
;
}
Home
~
Topic