[CLOSED] ComboBox SelectedItem in UserControl

  1. #1

    [CLOSED] ComboBox SelectedItem in UserControl

    I am still going around in circles on UserControlLoader and ComponentLoader. So I thought I would try something simple with UserControlLoader, but I can not retrieve the SelectedItem.Value of a combobox in the user control. What am I not remembering?

    OptionPage05.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void ClickBuildDescription(object sender, DirectEventArgs e)
        {
            Options05 uc = (Options05)this.uclOptions.UserControls[0];
    
            String description = uc.BuildDescription();
            X.Msg.Alert("Description from user control", description).Show();
        }
    </script>
    <!DOCTYPE html >
    <html>
    <head id="Head1" runat="server">
        <title>Load UserControls</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:Panel runat="server" Layout="BorderLayout" Height="100" Width="400">
            <Items>
                <ext:Panel runat="server" Title="Center" Region="Center">
                    <Items>
                        <ext:UserControlLoader ID="uclOptions" runat="server" Path="Options05.ascx" />
                    </Items>
                    <Buttons>
                        <ext:Button runat="server" Text="Description" OnDirectClick="ClickBuildDescription" />
                    </Buttons>
                </ext:Panel>
            </Items>
        </ext:Panel>
    </body>
    </html>
    Options05.ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Options05.ascx.cs" Inherits="Options05" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <ext:FieldSet ID="OptionFieldSet" runat="server" ClientIDMode="Static" Title="Options"
        Collapsible="true">
        <Items>
            <ext:Container ID="OptionsCat01" runat="server" ClientIDMode="Static">
                <Items>
                    <ext:ComboBox ID="Cat01Type" runat="server" FieldLabel="Option01 Types" AllowBlank="false"
                        Editable="false" IndicatorIcon="BulletRed">
                        <Items>
                            <ext:ListItem Value="F" Text="Full" />
                            <ext:ListItem Value="P" Text="Partial" />
                        </Items>
                    </ext:ComboBox>
                </Items>
            </ext:Container>
        </Items>
    </ext:FieldSet>
    Options05.ascx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Options05 : System.Web.UI.UserControl
    {
        public String BuildDescription()
        {
            String description = Cat01Type.SelectedItem.Value;
            return description;
        }
    }
    Last edited by Daniil; Apr 30, 2013 at 4:17 AM. Reason: [CLOSED]
  2. #2
    Hi Chris,

    I think you have to define:
    <form runat="server">
    Otherwise nothing is automatically submitted.

Similar Threads

  1. ComboBox and selectedItem.value
    By cwolcott in forum 1.x Help
    Replies: 3
    Last Post: Feb 01, 2012, 7:48 AM
  2. Replies: 4
    Last Post: Nov 30, 2011, 5:25 AM
  3. Replies: 0
    Last Post: Aug 03, 2011, 10:27 PM
  4. Replies: 4
    Last Post: Feb 02, 2010, 4:08 PM
  5. ComboBox's SelectedItem in MVC App
    By danni in forum 1.x Help
    Replies: 4
    Last Post: Oct 02, 2009, 5:06 PM

Posting Permissions