Internal Server Error: Control with ID 'Store1' not found

  1. #1

    Internal Server Error: Control with ID 'Store1' not found

    I have the following web user control page:

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="tempForm.ascx.cs" Inherits="WebSiteExt.tempForm" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void RefreshData(object sender, StoreReadDataEventArgs e)
        {
            Store store = sender as Store;
            store.DataSource = new object[] 
            { 
                new object[] { DateTime.Now.ToString() },
                new object[] { "item2" },
                new object[] { "item3" }
            };
            store.DataBind();
        }
    </script>
    
    <ext:Window ID="Window1" 
        runat="server"
        Width="400"
        Height="400"
        MinWidth="300"
        MinHeight="300"
        Layout="FitLayout"
        Resizable="true"
        Modal="true">
          <Items>
            <ext:FormPanel ID="FormPanelDomain" 
                runat="server"            
                BodyPadding="5">            
                <FieldDefaults LabelAlign="Right" LabelWidth="90" MsgTarget="Qtip" />
                <Items>
                  <ext:ComboBox ID="ComboBox1" runat="server" DisplayField="text">
                      <Store>
                          <ext:Store ID="Store1"
                              runat="server"
                              OnReadData="RefreshData"
                              AutoLoad="false">
                              <Model>
                                <ext:Model ID="Model1" runat="server">
                                  <Fields>
                                    <ext:ModelField Name="text" />
                                  </Fields>
                                </ext:Model>
                              </Model>
                              <Proxy>
                                <ext:PageProxy>
                                    <Reader>
                                        <ext:ArrayReader />
                                    </Reader>
                                </ext:PageProxy>
                              </Proxy>
                          </ext:Store>
                      </Store>
                  </ext:ComboBox>
                </Items>
            </ext:FormPanel>        
          </Items>
        </ext:Window>
    It's working perfectly in a simple and empty web form like this:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebFormTemp.aspx.cs" Inherits="WebSiteExt.WebFormTemp" %>
    <%@ Register TagPrefix="uc" TagName="form" Src="~/tempForm.ascx" %>
    <!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>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <uc:form id="form" runat="server" />
        </form>
    </body>
    </html>
    But in this page my store databind is not working because the store cannot be found:

    <%@ Page Language="C#" %>
    <%@ Import Namespace="Panel=Ext.Net.Panel" %>
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            Toolbar toolbar = new Toolbar();
            Ext.Net.Button buttonAdd = new Ext.Net.Button();
            buttonAdd.Icon = Icon.Add;
            buttonAdd.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(Click_Event);
            toolbar.Add(buttonAdd);
          
            Viewport viewport = new Viewport
            {
                Layout = "BorderLayout",
                Items = 
                { 
                  new Panel
                  {
                      Region = Region.West,
                      Title = "West",
                      Width = Unit.Pixel(225),
                      MinWidth = 225,
                      MaxWidth = 400,
                      Split = true,
                      Collapsible = true,
                      Items = { toolbar }
                  } 
                }
            };
    
            // Add Viewport to Page
            this.Controls.Add(viewport);
        }
    
        void Click_Event(object sender, DirectEventArgs e)
        {
          UserControlRendererConfig config = new UserControlRendererConfig
          {
            UserControlPath = "tempForm.ascx",
            SingleControl = true,
            Mode = RenderMode.RenderTo
          };
    
          config.BeforeRender += delegate(ComponentAddedEventArgs ce)
          {
            ce.Control.ID = BaseControl.GenerateID();
            e.ExtraParamsResponse.Add(new Ext.Net.Parameter("windowId", ce.Control.ConfigID));
          };
    
          UserControlRenderer.Render(config);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>Viewport with BorderLayout - Ext.NET Examples</title>
    </head>
    <body>
        <form id="form1" runat="server">
          <ext:ResourceManager ID="ResourceManager1" runat="server" />
        </form>
    </body>
    </html>
    Thank you in advance.
  2. #2
    Any dynamic control must be recreated on the server side to handle own events because each ASP.NET creates new instance of a page for each request
    Please read articles about dynamic ASP.NET controls if you have any additional questions about that issue
  3. #3
    Quote Originally Posted by Vladimir View Post
    Any dynamic control must be recreated on the server side to handle own events because each ASP.NET creates new instance of a page for each request
    Please read articles about dynamic ASP.NET controls if you have any additional questions about that issue
    Ok, I can realize why it's working when I included my user control tag in the ASPX page (like the first example). I understand that when I render it dynamically the store is not being found because it will be a new instance of a page.

    The store is being defined in the markup code, but if do it in the code behind the result is the same.

    Could you provide me a simple "hello world" example render a dynamic control recreating the store in the server side?

    Thanks.

Similar Threads

  1. Internal Server Error 500
    By Ganesh3.shirsath in forum 1.x Help
    Replies: 2
    Last Post: Feb 07, 2013, 9:37 AM
  2. Direct Method cause Internal Server Error.
    By Kaveh in forum 2.x Help
    Replies: 0
    Last Post: Apr 17, 2012, 2:44 PM
  3. Request failure : Internal Server Error
    By richard in forum 2.x Help
    Replies: 1
    Last Post: Mar 15, 2012, 12:16 PM
  4. Internal Server Error 500
    By Ganesh3.shirsath in forum 1.x Help
    Replies: 3
    Last Post: Jan 20, 2011, 2:07 PM
  5. Replies: 5
    Last Post: May 28, 2009, 5:03 AM

Tags for this Thread

Posting Permissions