radiobutton click and avoid page refresh

R

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!
 
N

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

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?
 
N

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!
 
S

Sarah

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

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top