<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="radiobuttonlist.aspx.cs"
    Inherits="ExtAspNet.Examples.form.radiobuttonlist" %>

<!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></title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <ext:PageManager ID="PageManager1" runat="server" />
    <ext:SimpleForm ID="SimpleForm1" Width="700px" runat="server" LabelWidth="160px"
        EnableBackgroundColor="true" BodyPadding="5px" ShowBorder="True" ShowHeader="True"
        Title="Simple Form">
        <Items>
            <ext:RadioButtonList ID="RadioButtonList1" Label="List 1" runat="server">
                <ext:RadioItem Text="Item 1" Value="value1" />
                <ext:RadioItem Text="Item 2" Value="value2" />
                <ext:RadioItem Text="Item 3" Value="value3" Selected="true" />
            </ext:RadioButtonList>
            <ext:Button ID="btnServerSetSelectedValue" CssClass="inline" Text="Select the first item of previous list" OnClick="btnServerSetSelectedValue_Click"
                runat="server">
            </ext:Button>
            <ext:Button ID="btnServerGetSelectedValue" CssClass="inline" Text="Get selected item of previous list" OnClick="btnServerGetSelectedValue_Click"
                runat="server">
            </ext:Button>
            <ext:Button ID="btnClientGetSelectedValue" Text="Get selected item of previous list (Via JavaScript)" EnablePostBack="false"
                OnClientClick="alertSelectedValue();" runat="server">
            </ext:Button>
            <ext:Label runat="server" Text="&nbsp;">
            </ext:Label>
            <ext:RadioButtonList ID="RadioButtonList2" Label="List 2 (One Column)" ColumnNumber="1" runat="server">
            </ext:RadioButtonList>
            <ext:Label ID="Label1" runat="server" Text="&nbsp;">
            </ext:Label>
            <ext:RadioButtonList ID="rblAutoPostBack" AutoPostBack="true" OnSelectedIndexChanged="rblAutoPostBack_SelectedIndexChanged"
                Label="List 3 (Auto PostBack)" ColumnNumber="3" runat="server" ShowRedStar="true" Required="true">
                <ext:RadioItem Text="Item 1" Value="value1" />
                <ext:RadioItem Text="Item 2" Value="value2" />
                <ext:RadioItem Text="Item 3" Value="value3" />
                <ext:RadioItem Text="Item 4" Value="value4" />
                <ext:RadioItem Text="Item 5" Value="value5" />
                <ext:RadioItem Text="Item 6" Value="value6" />
                <ext:RadioItem Text="Item 7" Value="value7" />
                <ext:RadioItem Text="Item 8" Value="value8" />
            </ext:RadioButtonList>
            <ext:Label ID="Label2" runat="server" Text="&nbsp;">
            </ext:Label>
            <ext:RadioButtonList ID="rblVertical" Label="List 4 (Vertical)" ColumnNumber="3" ColumnVertical="true"
                runat="server" ShowRedStar="true" Required="true">
                <ext:RadioItem Text="Item 1" Value="value1" />
                <ext:RadioItem Text="Item 2" Value="value2" />
                <ext:RadioItem Text="Item 3" Value="value3" />
                <ext:RadioItem Text="Item 4" Value="value4" />
                <ext:RadioItem Text="Item 5" Value="value5" />
                <ext:RadioItem Text="Item 6" Value="value6" />
                <ext:RadioItem Text="Item 7" Value="value7" />
                <ext:RadioItem Text="Item 8" Value="value8" />
            </ext:RadioButtonList>
            <ext:Button runat="server" ID="btnSubmit" ValidateForms="SimpleForm1" Text="Submit Form" OnClick="btnSubmit_Click">
            </ext:Button>
        </Items>
    </ext:SimpleForm>
    </form>
    <script type="text/javascript">

        function alertSelectedValue() {
            var list2 = Ext.getCmp('<%= RadioButtonList1.ClientID %>');
            var selectedRadio = list2.getValue();
            if (selectedRadio) {
                top.X.util.alert("Selected value of List 1: " + selectedRadio.getRawValue());
            } else {
                top.X.util.alert("No selection in List 1.");
            }
        }
    
    </script>
</body>
</html>
