Apr 25, 2013, 3:32 PM
[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
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.csusing 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]