Home All Groups Group Topic Archive Search About

radiobutton click and avoid page refresh

Author
2 Dec 2008 3:29 PM
rum23
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!

Author
4 Dec 2008 12:42 AM
Nathan Sokalski
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
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"rum23" <ru***@discussions.microsoft.com> wrote in message
news:9241C0D7-C101-4854-BAAE-C3DF8C14AC7D@microsoft.com...
>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!
Author
6 Jan 2009 6:13 PM
misunderstood
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?

Show quoteHide quote
"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
> njsokal***@hotmail.com
> http://www.nathansokalski.com/
>
> "rum23" <ru***@discussions.microsoft.com> wrote in message
> news:9241C0D7-C101-4854-BAAE-C3DF8C14AC7D@microsoft.com...
> >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!
>
>
>
Author
7 Jan 2009 5:32 AM
Nathan Sokalski
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
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"misunderstood" <misunderst***@discussions.microsoft.com> wrote in message
news:59D648F5-7E6E-4E23-98BC-52EB385E194B@microsoft.com...
> 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
>> njsokal***@hotmail.com
>> http://www.nathansokalski.com/
>>
>> "rum23" <ru***@discussions.microsoft.com> wrote in message
>> news:9241C0D7-C101-4854-BAAE-C3DF8C14AC7D@microsoft.com...
>> >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!
>>
>>
>>