Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4021870
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:24:17+00:00 2026-05-20T10:24:17+00:00

I have User Control <table style=border-width: 0> <tr> <td style=vertical-align: middle;> <asp:RadioButton ID=rdOption runat=server

  • 0

I have User Control

<table style="border-width: 0">
    <tr>
        <td style="vertical-align: middle;">
            <asp:RadioButton ID="rdOption" runat="server" Text="I m testing"  
                GroupName="Questions" oncheckedchanged="rdOption_CheckedChanged" 
                AutoPostBack="True"/>
        </td>
        <td style="vertical-align: middle; padding-left: 10px">
            <asp:TextBox ID="txtOthers" runat="server" CssClass="txtbox" Visible="false"></asp:TextBox>
        </td>
    </tr>
</table>

protected void Page_Load(object sender, EventArgs e)
    {
        rdOption.GroupName = "myGroup";
        rdOption.Text = Option.OptionDesc;
    }

on Survery.aspx I loaded that user control dynamically

 foreach (clsOptions option in _CurrentQuestion.Options)
        {
            UserControls_OptionField ctrl = Page.LoadControl("~/UserControls/OptionField.ascx") as UserControls_OptionField;
            ctrl.Option = option;
            pnlOption.Controls.Add(ctrl);
        }

Problem is that each option have diffrent group name shown below. Thats why options are not working properly and all option can be selected while in MCQs only one option can be selected.

<input id="ContentPlaceHolder1_ctl01_rdOption" type="radio" name="ctl00$ContentPlaceHolder1$ctl01$myGroup" value="rdOption">

<input id="ContentPlaceHolder1_ctl02_rdOption" type="radio" name="ctl00$ContentPlaceHolder1$ctl02$myGroup" value="rdOption">

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:24:18+00:00Added an answer on May 20, 2026 at 10:24 am

    I think that this is a bug that is in ASP.Net since 1.0(awesome, they have forgotten that completely ^^).

    You could try following solution that works for a Repeater(or any databound control) but should also work for your dynamic UserControls.

    The problem is that ASP.Net renders different unique names for different NamingContainers and therefore the RadioButtons get different GroupNames.

    http://weblogs.asp.net/joseguay/archive/2008/07/24/having-radiobuttons-on-a-repeater-or-datalist.aspx

    Put this in your HEAD section of your page’s:

    function SetUniqueRadioButton(nameregex, current)
    {
          re = new RegExp(nameregex);
          for(i = 0; i < document.forms[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;
    }
    

    Add the clientside onclick event to the RadioButtons with appropriate parameters:

    string script = "SetUniqueRadioButton('rdOption.*myGroup',this)";
    rdOption.Attributes.Add("onclick", script);
    

    [not tested]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have user control named DateTimeUC which has two textboxes on its markup: <asp:TextBox
This is the code I have: <body> <form id=form1 runat=server> <div> <asp:TextBox ID=txtInsertComments CssClass=expanding
<form id=Form1 method=post runat=server> <uc1:PageHeaderDisplay id=pageHeaderDisplay1 runat=server></uc1:PageHeaderDisplay> <asp:HiddenField runat=server ID=postedFormData /> <div style=display: none;
I have a User Control which returns a table of data, which in some
I have a user control in my asp.net web project. It displays the title
I have user control in my MVC2 app placed in the Content folder (it's
i have user control, which i render on several views. i want to show
I have a user control in a repeater that I need to pass data
I have a user control that is pretty basic. It contains several TextBox controls,
I have a user control ( gallery.ascx ) and I want to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.