我在.apsx页的代码是:
<asp:RadioButtonList ID="rblLogo" runat="server" RepeatDirection="Horizontal" OnSelectedIndexChanged="rblLogo_SelectedIndexChanged">
                            <asp:ListItem Selected="True" Value="1">88X31</asp:ListItem>
                            <asp:ListItem Value="2">114X23</asp:ListItem>
                        </asp:RadioButtonList>在.cs页的代码是:
protected void rblLogo_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (rblLogo.SelectedValue.ToString() == "1")
        {
            imgLogo.Width = Unit.Parse("88px");
            imgLogo.Height = Unit.Parse("31px");
        }
        else if (rblLogo.SelectedValue.ToString() == "2")
        {
            imgLogo.Width = Unit.Parse("114px");
            imgLogo.Height = Unit.Parse("23px");
        }
    }当我运行页面时,选择RadioButtonList控件页面上imgLogo没有什么变化。调试时发现我点这个RadioButtonList控件,它的事件rblLogo_SelectedIndexChanged根本就没有启用。请高手指教!

解决方案 »

  1.   

    AutoPostBack="True"
      

  2.   


    <asp:RadioButtonList ID="rblLogo" AutoPostBack="True" runat="server" RepeatDirection="Horizontal" OnSelectedIndexChanged="rblLogo_SelectedIndexChanged">
                                <asp:ListItem Selected="True" Value="1">88X31</asp:ListItem>
                                <asp:ListItem Value="2">114X23</asp:ListItem>
                            </asp:RadioButtonList>加上 AutoPostBack="True"