View Full Version : [CLOSED] How to register items on page load from code behind when using a masterpage

Jan 18, 2014, 9:50 AM

I run into some trouble when adding items on page load while using a master page. I found this post (http://forums.ext.net/showthread.php?1367-Loading-a-UserControl-(ascx)-to-a-page) about Ext.Net v1.x but I wasn't able to find the equivalent in v2.x. How do I address this BodyControls issue in my example?

Thank you very muche.


<%@ Master Language="C#" %>

<!DOCTYPE html>

<script runat="server">


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<ext:ResourceManager ID="ResourceManager" runat="server" Locale="de-CH"></ext:ResourceManager>
<asp:ContentPlaceHolder id="CPH_HEAD" runat="server">
<form id="form1" runat="server">
<asp:ContentPlaceHolder id="CPH_BODY" runat="server">



<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
if (!X.IsAjaxRequest)
ComboBox cbbTest = new ComboBox
ID = "cbbID",
FieldLabel = "Year",
Items = { new Ext.Net.ListItem("2014", "2014") },
Listeners = { Select = { Handler = "App.direct.onSelect()" } }
container.Items.Add(cbbTest); // <<--- not working like this

public void onSelect()
X.Msg.Alert("Selected Year", X.GetCmp<ComboBox>("cbbID").SelectedItem.Value).Show();


<asp:Content ID="Content1" ContentPlaceHolderID="CPH_HEAD" Runat="Server">

<asp:Content ID="Content2" ContentPlaceHolderID="CPH_BODY" Runat="Server">

<ext:Container ID="container" runat="server" Padding="5"></ext:Container>


Jan 20, 2014, 4:18 AM
Hi @tMp,

Could you, please, clarify what exactly doesn't work in your sample?

The ComboBox is rendered for me. Not for you?

If you are about this

returns nothing, then you should replace it with


By default, a control's client id is combined with INamingContainers' ids.

Jan 20, 2014, 6:50 AM

Thank you, I was looking for the last part, which solved my problem.