[CLOSED] [1.0]Problem with directMethod from custom Combobox

  1. #1

    [CLOSED] [1.0]Problem with directMethod from custom Combobox

    Hi, i have a problem with directmethod.

    I create a compositefield server-side with a combobox inside.
    The combobox is linked with a store in the page and had a directmethod on select attached.
    I can create the compositefield whit combo correctly, but when i select an item in the combo, instead of calling directmethod, appears an error:

    The control with ID 'comboExample' not found

    [HttpException (0x80004005): The control with ID 'comboExample' not found]
    Ext.Net.ResourceManager.RaisePostBackEvent(String eventArgument) +1738
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +29
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
    it can't find the control.
    there is the code:


    <%@ Page Language="C#" AutoEventWireup="true"  %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Store1.DataSource = new object[]
            {
                new object[] { "AL", "Alabama", "The Heart of Dixie" },
                new object[] { "AK", "Alaska", "The Land of the Midnight Sun" },
                new object[] { "AZ", "Arizona", "The Grand Canyon State" },
                new object[] { "AR", "Arkansas", "The Natural State" },
                new object[] { "CA", "California", "The Golden State" }
            };
    
            this.Store1.DataBind();
    
        }
    
        protected void creaRiga(object sender, DirectEventArgs e)
        {
            CompositeField cmp = BuildComposite();
            cmp.AddTo(this.pnlCat1);
        }
    
        private CompositeField BuildComposite()
        {
            ComboBox cmb = new ComboBox
            {
                ID = "comboExample",
                TriggerAction = TriggerAction.All,
                DisplayField = "state",
                ValueField = "abbr",
                EmptyText = "choose",
                Width = Unit.Pixel(200),
                Editable = false,
                Enabled = false
            };
            cmb.Store.Add(Store1);
            cmb.DirectEvents.Select.ExtraParams.Add(new Ext.Net.Parameter("Condizione", "2"));
            cmb.DirectEvents.Select.ExtraParams.Add(new Ext.Net.Parameter("Riga", "2"));
            cmb.DirectEvents.Select.Event += new ComponentDirectEvent.DirectEventHandler(caricaCombo);
            Store1.DataBind();
            CompositeField cmpF = new CompositeField
            {
                ID = "Composite2Cat1",
                Items =
                        {
                            cmb
                        }
            };
    
            return cmpF;
        }
    
    
        protected void caricaCombo(object sender, DirectEventArgs e)
        {
            //do something
        }
    
    </script>
    
    <!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 id="Head2" runat="server">
        <title>Example</title>
        <link href="App_Themes/examples.css" rel="stylesheet" type="text/css" />
        <link href="App_Themes/main.css" rel="stylesheet" type="text/css" /> 
        
        <script type="text/javascript">
    
        
         </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
             <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="abbr" />
                            <ext:RecordField Name="state" />
                            <ext:RecordField Name="nick" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>            
            </ext:Store>
    
            <ext:Panel ID="pnlCat1" runat="server" AutoWidth="true" Padding="4" Title="Condizione 1" >
                <TopBar>
                    <ext:Toolbar ID="Toolbar2" runat="server">
                        <Items>
                            <ext:ToolbarFill ID="ToolbarFill2" runat="server" />
                            <ext:Button ID="Button4" runat="server" Icon="Add">
                                <DirectEvents>
                                    <Click OnEvent="creaRiga"></Click>
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                </Items>
            </ext:Panel>
    
        </form>
    </body>
    </html>
    Regards.
    Last edited by Daniil; Sep 29, 2010 at 6:43 PM. Reason: [CLOSED]
  2. #2
    Hi capecod,

    Please note that DirectEvent is not DirectMethod. Though these things are very alike.

    Unfortunately the DirectEvent handler needs creating Control during the request (for example, in the Page_Load). It's because of the ASP.NET is stateless system.

    Please provide use with more details about your scenario. What exactly operations would you like to do with ComboBox on server side?
    Maybe a DirectMethod would help.
  3. #3
    Hi,

    Any dynamic ASP.NET control must be recreated on each request because ASP.NET stateless system.
    You can use DirectMethod instead DirectEvent to avoid control recreation

Similar Threads

  1. [CLOSED] DirectMethod's problem
    By softmachine2011 in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 06, 2012, 3:56 PM
  2. DirectMethod problem
    By abhijit in forum 1.x Help
    Replies: 4
    Last Post: Dec 23, 2011, 12:43 PM
  3. Help!!!ComboBox Custom Search 's Problem~
    By st.leo in forum 1.x Help
    Replies: 2
    Last Post: Nov 24, 2010, 9:20 AM
  4. ComboBox Custom Search 's Problem~
    By st.leo in forum 1.x Help
    Replies: 1
    Last Post: Nov 18, 2010, 2:00 AM
  5. [CLOSED] Manipulating ComboBox Items via DirectMethod
    By ewgoforth in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 02, 2010, 7:23 PM

Posting Permissions