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

  • Home
  • SEARCH
  • 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 233647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:07:12+00:00 2026-05-11T20:07:12+00:00

We had some strange issues when using UpdatePanels and RadioButtonLists in that a PostBack

  • 0

We had some “strange” issues when using UpdatePanels and RadioButtonLists in that a PostBack was not occuring when you changed the values.

I’ve managed to track down the issue in that it occurs when the value of the RadioButtonList is set in the PreLoad of a page and you are re-selecting this initial value.

I have the full code of the ASP page and the CodeBehind below.

ASPX:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RBLPostBackIssue._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <div>
    <asp:Label ID="Label1" runat="server"></asp:Label>
    <asp:RadioButtonList ID="RadioButtonList1" AutoPostBack="true" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" RepeatDirection="Horizontal" runat="server">
        <asp:ListItem>Yes</asp:ListItem>
        <asp:ListItem>No</asp:ListItem>
    </asp:RadioButtonList>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:PlaceHolder ID="PlaceHolder1" runat="server">
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </asp:PlaceHolder>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="RadioButtonList1" EventName="SelectedIndexChanged" />
        </Triggers>
    </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

CodeBehind:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace RBLPostBackIssue
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_PreLoad(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                switch (new Random().Next(2))
                {
                    case 0:
                        Label1.Text = "Initial value set to Yes";
                        RadioButtonList1.SelectedValue = "Yes";
                        break;
                    case 1:
                        Label1.Text = "Initial value set to No";
                        RadioButtonList1.SelectedValue = "No";
                        break;
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ShowHideLogic();
            }
        }

        private void ShowHideLogic()
        {
            PlaceHolder1.Visible = RadioButtonList1.SelectedValue.ToLower().Contains("yes");
        }

        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ShowHideLogic();
        }
    }
}

The following occurs.

  • The first load the RadioButtonList is set randomly to Yes or No.
  • You change the value of the RadioButtonList and the textbox will show/hide accordingly.
  • You change the value back to it’s original value and no postback occurs at all.
  • No matter how often you change the value a postback will only occur if you do NOT select the initial value.

The setting of the inital value in the PreLoad comes from some legacy code that we would prefer not to change. Any change there will require a substantial amount of testing and re-deploying to a large number of other projects.

The only solution I have found is to not use a Trigger for the RadioButtonList but to put it within the UpdatePanel. Whislt this is a solution in some cases, it is not ideal as UI does not allways allow this.

I guess my question is, has anyone else had this problem, do you know of another solution to it, or am I just being stupid and have missed something obvious?

  • 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-11T20:07:12+00:00Added an answer on May 11, 2026 at 8:07 pm

    This is down to how ASP.Net renders the HTML for the radio button list. If you view the source of the page when it’s first loaded, the <input> element that’s initially selected will have a checked="checked" attribute. The <input> element that isn’t initially selected will instead have a onclick="javascript:setTimeout('__doPostBack...')" attribute.

    So, a postback will only occur if you change the selected item, fair enough.

    However, as you’re using an UpdatePanel, the whole page isn’t being re-rendered on post-back, just the contents of the update panel. So, if Yes is initially selected, clicking No will post back and the text box will be removed. But the HTML for the radio buttons hasn’t changed, so clicking Yes now will not post back, as there’s no javascript to do this.

    You can fix all this by either putting the radio button list in the same UpdatePanel as the PlaceHolder, or by putting the radio button list in its own UpdatePanel. This will ensure the HTML that renders the radio buttons will be updated after each post back, and things will work as expected.

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

Sidebar

Ask A Question

Stats

  • Questions 144k
  • Answers 144k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer All of the examples you provided can be helpful to… May 12, 2026 at 8:35 am
  • Editorial Team
    Editorial Team added an answer I sounds like you want to be using a Modal… May 12, 2026 at 8:35 am
  • Editorial Team
    Editorial Team added an answer urllib module automatically retrieves settings from registry when no proxies… May 12, 2026 at 8:35 am

Related Questions

We had discovered strange behaviour of popups in IE8. In IE7 and IE6 our
If I create classes, that are used at the moment only in a single
I was testing on a customer's box this afternoon which has Windows Vista (He
Im not sure if i have explaned this the best i can but, here

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.