Welcome Guest Search | Active Topics | Sign In | Register

RadioButtonList and Callbackpanel Options
Seltris
Posted: Wednesday, August 6, 2008 12:38:04 AM
Rank: Member
Groups: Member

Joined: 10/4/2007
Posts: 20
Hi Guys,

i've used RadioButtonList trigger for calbackpanel. I've started with first item selected. If i select other item the callback is called but when i select the first item the callback is not call.
I've resolved (in test code) putting the RadioButtonList in callback but i dont make it in my application.

Thanks
YBT Seltris


Code: HTML/ASPX
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test2.aspx.vb" Inherits="Administration_Test2" %>

<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<!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>Pagina senza titolo</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <eo:CallbackPanel ID="CallbackPanel1" runat="server" Height="150px" Triggers="{ControlID:RadioButtonList1;Parameter:}"
            Width="200px">
             <asp:Label ID="Label1" runat="server" Text="1"></asp:Label></eo:CallbackPanel>
        <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
            <asp:ListItem Selected="True">1</asp:ListItem>
            <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>3</asp:ListItem>
        </asp:RadioButtonList>
    
    </div>
    </form>
</body>
</html>


Code: Visual Basic.NET
Partial Class Administration_Test2
    Inherits System.Web.UI.Page

    Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged
        Me.Label1.Text = Me.RadioButtonList1.SelectedValue
    End Sub

End Class
eo_support
Posted: Thursday, August 7, 2008 12:27:32 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
Hi,

This is normal. One of the basic rules for an AJAX callback to work is state consistency: All the participant's state must be consistent with each other. This applies to any Web Form based AJAX solution. You can try the same code with ASP.NET UpdatePanel and you will get the same result.

When a RadioButtonList is clicked, it's state is changed. The server sees this changed state. However the client side HTML for the RadioButtonList is not updated according to reflect this state. Thus an inconsistency occurs and issues arise.

Not all controls "care" about state consistency, but most complicates controls do. Most simple controls do not. That's why when using simple controls, such as Button as trigger always works regardless the button is inside or outside the Callback/UpdatePanel. However that does not imply everyone will work. RadioButtonList is one that won't work that way.

Moving the control into the CallbackPanel is one way to maintain state consistency. Another way is to use an additional CallbackPanel, placing RadioButtonList into that CallbackPanel and then set both CallbackPanels GroupName to the same value. That way both CallbackPanel will update together, but are still physically apart.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.