[CLOSED] The control with ID 'MainContent_ctl69' not found

  1. #1

    [CLOSED] The control with ID 'MainContent_ctl69' not found

    I got the error message when I added MasterPageFile in the aspx file.

    here is my code:

    aspx
    <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent" >
    .................
    <ext:Portlet ID="PortletGroupView" runat="server" Layout="TableLayout" Closable="false" Draggable="false" Frame="false" Collapsible="false" Border="false">
    <LayoutConfig>
    <ext:TableLayoutConfig Columns="3" />
    </LayoutConfig>
    <Items>
    </Items>
    </ext:Portlet>
    ........................
    </asp:Content>
    C# Code
        public class GROUP_HOST
        {
            public String GROUP_NAME { get; set; }
            public String DURATION { get; set; }
            public String COUNT_OK { get; set; }
            public String COUNT_WARNING { get; set; }
            public String COUNT_NG { get; set; }
        }
    
        public partial class Default : System.Web.UI.Page
        {
            protected void Load_Group_View()
            {
                List<GROUP_HOST> ghlst = new List<GROUP_HOST>();
                for (int i = 1; i < 10; i++)
                {
                    GROUP_HOST gh = new GROUP_HOST();
                    gh.GROUP_NAME = "Group_" + i;
                    gh.DURATION = i * 2 + "D" + 1 * i + "H" + 2 * i + "m";
                    gh.COUNT_NG = 2 * i + "";
                    gh.COUNT_OK = 3 * i + "";
                    gh.COUNT_WARNING = 1 * i + "";
                    ghlst.Add(gh);
                }
                foreach (GROUP_HOST gh in ghlst)
                {
                    Ext.Net.Button btnOK = new Ext.Net.Button
                    {
                        Scale = ButtonScale.Large,
                        Width = 50,
                        Cls = "btn-green",
                        Text = "<span style='color:while;'>"+gh.COUNT_OK+"</span>",
                        AutoDataBind = true
                    };
                    Ext.Net.Button btnWarning = new Ext.Net.Button
                    {
                        Scale = ButtonScale.Large,
                        Width = 50,
                        Cls = "btn-yellow",
                        Text = "<span style='color:while;'>" + gh.COUNT_WARNING + "</span>",
                        AutoDataBind = true
                    };
                    Ext.Net.Button btnNG = new Ext.Net.Button
                    {
                        Scale = ButtonScale.Large,
                        Width = 50,
                        Cls = "btn-red",
                        Text = "<span style='color:while;'>" + gh.COUNT_NG + "</span>",
                        AutoDataBind = true
                    };
    
                    btnOK.DirectEvents.Click.Event += GroupViewClick;
                    btnWarning.DirectEvents.Click.Event += GroupViewClick;
                    btnNG.DirectEvents.Click.Event += GroupViewClick;
    
                    Ext.Net.Panel pn = new Ext.Net.Panel
                    {
                        Title = gh.GROUP_NAME,
                        FrameHeader = true,
                        BodyPadding = 10,
                        Frame = true,
                        Width = 200,
                        Items = { 
                            new Ext.Net.Label{
                                Text = gh.DURATION,
                                Height = 100,
                                Width=100
                            },
                            new Container{
                                Items = {
                                btnOK,btnWarning,btnNG
                                }
                            }
                        }
    
                    };
                    this.PortletGroupView.Items.Add(pn);
                }
            }
    
            protected void GroupViewClick(object sender, EventArgs e)
            {
                String aaa = ((Ext.Net.Button)sender).Text;
            }
    }
    When I trigger the button click event, will get error "The control with ID 'MainContent_ctl69' not found".
    but it was work when I didn't use MasterPageFile, please help, thanks a lot.
    Last edited by Daniil; Mar 18, 2014 at 12:48 PM. Reason: [CLOSED]
  2. #2
    Hi @Geenin,

    Could you, please, clarify where the Load_Group_View method is being called?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @Geenin,

    Could you, please, clarify where the Load_Group_View method is being called?
    protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    this.Load_Group_View();
                }
            }
    It's called by Page_Load

    Geenin
  4. #4
    Thanks.

    Quote Originally Posted by Geenin View Post
    but it was work when I didn't use MasterPageFile, please help, thanks a lot.
    Even without a master page, if you created the Buttons under this condition
    if (!IsPostBack)
    then I would say it should not work.

    A control's DirectEvent requires an instance of that control on client side. This condition
    if (!IsPostBack)
    means that you don't recreate the Buttons when a DirectEvent occurs.

    Also I would suggest to set up IDs for the Buttons explicitly.
  5. #5
    Quote Originally Posted by Daniil View Post
    Thanks.



    Even without a master page, if you created the Buttons under this condition
    if (!IsPostBack)
    then I would say it should not work.

    A control's DirectEvent requires an instance of that control on client side. This condition
    if (!IsPostBack)
    means that you don't recreate the Buttons when a DirectEvent occurs.

    Also I would suggest to set up IDs for the Buttons explicitly.

    Thanks Daniil ! It works... very appreciate....... :-)


    Geenin

Similar Threads

  1. Replies: 8
    Last Post: Nov 28, 2013, 6:39 AM
  2. Replies: 5
    Last Post: May 28, 2013, 7:20 PM
  3. The Control Not Found!
    By flaviodamaia in forum 2.x Help
    Replies: 1
    Last Post: Feb 20, 2013, 1:51 PM
  4. The control with ID 'ctl04_AddDoc' not found
    By geraldf in forum 2.x Help
    Replies: 1
    Last Post: Aug 24, 2012, 2:45 PM
  5. Replies: 2
    Last Post: Nov 02, 2011, 7:07 AM

Posting Permissions