radiobutton click and avoid page refresh

Discussion in 'ASP .Net Web Controls' started by rum23, Dec 2, 2008.

  1. rum23

    rum23 Guest

    I have a list of radio buttons on a page like this

    <asp:UpdatePanel ID="updAuthoptions" runat="server">

    <asp:panel ID="panelAuthorizationType" runat="server">
    <asp:RadioButton ID="RadioButton1"
    GroupName="rbAuthType" runat="server" Text="radio 1"

    OnCheckedChanged="RadioButton1_CheckedChanged" AutoPostBack="true">
    <asp:RadioButton ID="RadioButton2"
    GroupName="rbAuthType" runat="server" Text="radio 2"

    OnCheckedChanged="RadioButton2_CheckedChanged" AutoPostBack="true">
    <asp:RadioButton ID="RadioButton3"
    GroupName="rbAuthType" runat="server" Text="radio 3"

    OnCheckedChanged="RadioButton3_CheckedChanged" AutoPostBack="true">
    <asp:AsyncPostBackTrigger ControlID="RadioButton1"
    EventName="RadioButton1_CheckedChanged" />
    <asp:AsyncPostBackTrigger ControlID="RadioButton2"
    EventName="RadioButton2_CheckedChanged" />
    <asp:AsyncPostBackTrigger ControlID="RadioButton3"
    EventName="RadioButton3_CheckedChanged" />

    Based on the radio button click, I will be enabling/disabling other controls
    on the page. Now, I want to do the enabling and disabling of controls without
    the page refresh. However, with the code above, the page refreshes whenever
    radiobutton1 or radiobutton2 or radiobutton3 is clicked. If I don't set the
    Autopoastback, the event is not even firing. What wrong am I doing? please

    rum23, Dec 2, 2008
    1. Advertisements

  2. Try adding the following properties to your UpdatePanel:

    <asp:UpdatePanel ID="updAuthoptions" runat="server"
    ChildrenAsTriggers="false" UpdateMode="Conditional">

    By default, any child controls (anything in the ContentTemplate) are
    automatically added as Triggers. You can use the ChildrenAsTriggers property
    to change this. Also, by default the controls in the UpdatePanel are updated
    on every postback. You can set the UpdateMode property to "Conditional" to
    specify that it should only be updated when triggered by one of the
    Triggers. I nearly always use ChildrenAsTriggers="false" and
    UpdateMode="Conditional" because it gives you more control over the
    functionality, but depending on the purpose of the pages you are writing
    your usage may be different. A great book on ASP.NET AJAX, which is where I
    learned the info I have given you above, is "Introducing Microsoft ASP.NET
    AJAX" by Dino Esposito from Microsoft Press. Hopefully this helps.
    Nathan Sokalski, Dec 4, 2008
    1. Advertisements

  3. Hi,
    I have the same issue with radio buttons. I tried <asp:UpdatePanel
    ID="updAuthoptions" runat="server"
    My requirement is that another set radiobuttons(in a panel) need to get
    enabled when an option is chosen from the first radio button list .
    The page doesn't jump, but then the 2nd set of radiobuttons does not get
    enabled, although the control goes to its selected index changed event.
    Could you tell me if I am missing anything?
    misunderstood, Jan 6, 2009
  4. It may be easier for me to help you if you post your current code. Until
    then, it sounds like you need to use the Triggers control of the UpdatePanel
    to use the first RadioButtonList as a Trigger. If you post your code I can
    show you how you should do this for your situation. Good Luck!
    Nathan Sokalski, Jan 7, 2009
  5. rum23

    Sarah Guest

    works on my case! I need to open a new page and keep old page not refresh some divs.
    Thanks very much!
    Sarah, Feb 15, 2011
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.