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">
    <ContentTemplate>

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

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

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

    OnCheckedChanged="RadioButton3_CheckedChanged" AutoPostBack="true">
    </asp:RadioButton>
    </td>
    </tr>
    </table>
    </asp:panel>
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="RadioButton1"
    EventName="RadioButton1_CheckedChanged" />
    <asp:AsyncPostBackTrigger ControlID="RadioButton2"
    EventName="RadioButton2_CheckedChanged" />
    <asp:AsyncPostBackTrigger ControlID="RadioButton3"
    EventName="RadioButton3_CheckedChanged" />
    </Triggers>
    </asp:UpdatePanel>

    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
    help.

    Thanks!
    rum23, Dec 2, 2008
    #1
    1. Advertising

  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

    http://www.nathansokalski.com/

    "rum23" <> wrote in message
    news:...
    >I have a list of radio buttons on a page like this
    >
    >
    > <asp:UpdatePanel ID="updAuthoptions" runat="server">
    > <ContentTemplate>
    >
    > <asp:panel ID="panelAuthorizationType" runat="server">
    > <table>
    > <tr>
    > <td>
    > <asp:RadioButton ID="RadioButton1"
    > GroupName="rbAuthType" runat="server" Text="radio 1"
    >
    > OnCheckedChanged="RadioButton1_CheckedChanged" AutoPostBack="true">
    > </asp:RadioButton>
    > </td>
    > </tr>
    > <tr>
    > <td>
    > <asp:RadioButton ID="RadioButton2"
    > GroupName="rbAuthType" runat="server" Text="radio 2"
    >
    > OnCheckedChanged="RadioButton2_CheckedChanged" AutoPostBack="true">
    > </asp:RadioButton>
    > </td>
    > </tr>
    > <tr>
    > <td>
    > <asp:RadioButton ID="RadioButton3"
    > GroupName="rbAuthType" runat="server" Text="radio 3"
    >
    > OnCheckedChanged="RadioButton3_CheckedChanged" AutoPostBack="true">
    > </asp:RadioButton>
    > </td>
    > </tr>
    > </table>
    > </asp:panel>
    > </ContentTemplate>
    > <Triggers>
    > <asp:AsyncPostBackTrigger ControlID="RadioButton1"
    > EventName="RadioButton1_CheckedChanged" />
    > <asp:AsyncPostBackTrigger ControlID="RadioButton2"
    > EventName="RadioButton2_CheckedChanged" />
    > <asp:AsyncPostBackTrigger ControlID="RadioButton3"
    > EventName="RadioButton3_CheckedChanged" />
    > </Triggers>
    > </asp:UpdatePanel>
    >
    > 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
    > help.
    >
    > Thanks!
    Nathan Sokalski, Dec 4, 2008
    #2
    1. Advertising

  3. Hi,
    I have the same issue with radio buttons. I tried <asp:UpdatePanel
    ID="updAuthoptions" runat="server"
    > ChildrenAsTriggers="false" UpdateMode="Conditional">.

    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?

    "Nathan Sokalski" wrote:

    > 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
    >
    > http://www.nathansokalski.com/
    >
    > "rum23" <> wrote in message
    > news:...
    > >I have a list of radio buttons on a page like this
    > >
    > >
    > > <asp:UpdatePanel ID="updAuthoptions" runat="server">
    > > <ContentTemplate>
    > >
    > > <asp:panel ID="panelAuthorizationType" runat="server">
    > > <table>
    > > <tr>
    > > <td>
    > > <asp:RadioButton ID="RadioButton1"
    > > GroupName="rbAuthType" runat="server" Text="radio 1"
    > >
    > > OnCheckedChanged="RadioButton1_CheckedChanged" AutoPostBack="true">
    > > </asp:RadioButton>
    > > </td>
    > > </tr>
    > > <tr>
    > > <td>
    > > <asp:RadioButton ID="RadioButton2"
    > > GroupName="rbAuthType" runat="server" Text="radio 2"
    > >
    > > OnCheckedChanged="RadioButton2_CheckedChanged" AutoPostBack="true">
    > > </asp:RadioButton>
    > > </td>
    > > </tr>
    > > <tr>
    > > <td>
    > > <asp:RadioButton ID="RadioButton3"
    > > GroupName="rbAuthType" runat="server" Text="radio 3"
    > >
    > > OnCheckedChanged="RadioButton3_CheckedChanged" AutoPostBack="true">
    > > </asp:RadioButton>
    > > </td>
    > > </tr>
    > > </table>
    > > </asp:panel>
    > > </ContentTemplate>
    > > <Triggers>
    > > <asp:AsyncPostBackTrigger ControlID="RadioButton1"
    > > EventName="RadioButton1_CheckedChanged" />
    > > <asp:AsyncPostBackTrigger ControlID="RadioButton2"
    > > EventName="RadioButton2_CheckedChanged" />
    > > <asp:AsyncPostBackTrigger ControlID="RadioButton3"
    > > EventName="RadioButton3_CheckedChanged" />
    > > </Triggers>
    > > </asp:UpdatePanel>
    > >
    > > 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
    > > help.
    > >
    > > Thanks!

    >
    >
    >
    misunderstood, Jan 6, 2009
    #3
  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

    http://www.nathansokalski.com/

    "misunderstood" <> wrote in message
    news:...
    > Hi,
    > I have the same issue with radio buttons. I tried <asp:UpdatePanel
    > ID="updAuthoptions" runat="server"
    >> ChildrenAsTriggers="false" UpdateMode="Conditional">.

    > 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?
    >
    > "Nathan Sokalski" wrote:
    >
    >> 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
    >>
    >> http://www.nathansokalski.com/
    >>
    >> "rum23" <> wrote in message
    >> news:...
    >> >I have a list of radio buttons on a page like this
    >> >
    >> >
    >> > <asp:UpdatePanel ID="updAuthoptions" runat="server">
    >> > <ContentTemplate>
    >> >
    >> > <asp:panel ID="panelAuthorizationType" runat="server">
    >> > <table>
    >> > <tr>
    >> > <td>
    >> > <asp:RadioButton
    >> > ID="RadioButton1"
    >> > GroupName="rbAuthType" runat="server" Text="radio 1"
    >> >
    >> > OnCheckedChanged="RadioButton1_CheckedChanged" AutoPostBack="true">
    >> > </asp:RadioButton>
    >> > </td>
    >> > </tr>
    >> > <tr>
    >> > <td>
    >> > <asp:RadioButton
    >> > ID="RadioButton2"
    >> > GroupName="rbAuthType" runat="server" Text="radio 2"
    >> >
    >> > OnCheckedChanged="RadioButton2_CheckedChanged" AutoPostBack="true">
    >> > </asp:RadioButton>
    >> > </td>
    >> > </tr>
    >> > <tr>
    >> > <td>
    >> > <asp:RadioButton
    >> > ID="RadioButton3"
    >> > GroupName="rbAuthType" runat="server" Text="radio 3"
    >> >
    >> > OnCheckedChanged="RadioButton3_CheckedChanged" AutoPostBack="true">
    >> > </asp:RadioButton>
    >> > </td>
    >> > </tr>
    >> > </table>
    >> > </asp:panel>
    >> > </ContentTemplate>
    >> > <Triggers>
    >> > <asp:AsyncPostBackTrigger ControlID="RadioButton1"
    >> > EventName="RadioButton1_CheckedChanged" />
    >> > <asp:AsyncPostBackTrigger ControlID="RadioButton2"
    >> > EventName="RadioButton2_CheckedChanged" />
    >> > <asp:AsyncPostBackTrigger ControlID="RadioButton3"
    >> > EventName="RadioButton3_CheckedChanged" />
    >> > </Triggers>
    >> > </asp:UpdatePanel>
    >> >
    >> > 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
    >> > help.
    >> >
    >> > Thanks!

    >>
    >>
    >>
    Nathan Sokalski, Jan 7, 2009
    #4
  5. rum23

    Sarah Guest

    Re: Re: radiobutton click and avoid page refresh

    works on my case! I need to open a new page and keep old page not refresh some divs.
    Thanks very much!

    > On Tuesday, December 02, 2008 10:29 AM rum2 wrote:


    > I have a list of radio buttons on a page like this
    >
    >
    > <asp:UpdatePanel ID="updAuthoptions" runat="server">
    > <ContentTemplate>
    >
    > <asp:panel ID="panelAuthorizationType" runat="server">
    > <table>
    > <tr>
    > <td>
    > <asp:RadioButton ID="RadioButton1"
    > GroupName="rbAuthType" runat="server" Text="radio 1"
    >
    > OnCheckedChanged="RadioButton1_CheckedChanged" AutoPostBack="true">
    > </asp:RadioButton>
    > </td>
    > </tr>
    > <tr>
    > <td>
    > <asp:RadioButton ID="RadioButton2"
    > GroupName="rbAuthType" runat="server" Text="radio 2"
    >
    > OnCheckedChanged="RadioButton2_CheckedChanged" AutoPostBack="true">
    > </asp:RadioButton>
    > </td>
    > </tr>
    > <tr>
    > <td>
    > <asp:RadioButton ID="RadioButton3"
    > GroupName="rbAuthType" runat="server" Text="radio 3"
    >
    > OnCheckedChanged="RadioButton3_CheckedChanged" AutoPostBack="true">
    > </asp:RadioButton>
    > </td>
    > </tr>
    > </table>
    > </asp:panel>
    > </ContentTemplate>
    > <Triggers>
    > <asp:AsyncPostBackTrigger ControlID="RadioButton1"
    > EventName="RadioButton1_CheckedChanged" />
    > <asp:AsyncPostBackTrigger ControlID="RadioButton2"
    > EventName="RadioButton2_CheckedChanged" />
    > <asp:AsyncPostBackTrigger ControlID="RadioButton3"
    > EventName="RadioButton3_CheckedChanged" />
    > </Triggers>
    > </asp:UpdatePanel>
    >
    > 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
    > help.
    >
    > Thanks!



    >> On Wednesday, December 03, 2008 7:42 PM Nathan Sokalski wrote:


    >> 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
    >>
    >> http://www.nathansokalski.com/
    >>
    >> "rum23" <> wrote in message
    >> news:...



    >>> On Tuesday, January 06, 2009 1:13 PM misunderstoo wrote:


    >>> 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?
    >>>
    >>> "Nathan Sokalski" wrote:



    >>>> On Wednesday, January 07, 2009 12:32 AM Nathan Sokalski wrote:


    >>>> 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
    >>>>
    >>>> http://www.nathansokalski.com/
    >>>>
    >>>> "misunderstood" <> wrote in message
    >>>> news:...



    >>>> Submitted via EggHeadCafe
    >>>> ASP.NET Generic Cookie Utility Class
    >>>> http://www.eggheadcafe.com/tutorial...66a7/aspnet-generic-cookie-utility-class.aspx
    Sarah, Feb 15, 2011
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lenny Shprekher
    Replies:
    0
    Views:
    2,318
    Lenny Shprekher
    Feb 23, 2005
  2. Luis Esteban Valencia Muñoz
    Replies:
    0
    Views:
    751
    Luis Esteban Valencia Muñoz
    Jun 3, 2005
  3. =?Utf-8?B?UHJpeWE=?=

    Avoid calling events on page refresh

    =?Utf-8?B?UHJpeWE=?=, Feb 21, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    961
    George Ter-Saakov
    Feb 21, 2006
  4. Alexander Malkis
    Replies:
    8
    Views:
    508
    Alexander Malkis
    Apr 14, 2004
  5. Roger23
    Replies:
    2
    Views:
    985
    Roger23
    Oct 12, 2006
Loading...

Share This Page