[CLOSED] WebService Proxy crashes when I try to pass a Hidden field for <AutoLoadParams>

  1. #1

    [CLOSED] WebService Proxy crashes when I try to pass a Hidden field for <AutoLoadParams>

    When I used the code below for the <AutoLoadParams> it works because I get the value of '6' in my Handler.ashx page.

                 <AutoLoadParams>
                        <ext:Parameter Name="lineID" Value="6" Mode="Raw" /> 
                    </AutoLoadParams>
    but when I try to pass in the Parameter for the Hidden field, it breaks !
    ERROR: "Microsoft JScript runtime error: 'App.hdLineId' is null or not an object"
                 <AutoLoadParams>
                        <ext:Parameter Name="lineID" Value="#{hdLineId}.getValue()" Mode="Raw" /> 
                    </AutoLoadParams>

    .aspx
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" TagPrefix="ext" Namespace="Ext.Net" %>
    <script runat="server">   
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
    
    
            }
        }
    
    </script>
    <html>
    <head>
        <title>Example of Issue </title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" Title="Test" Frame="true" Height="300">
            <Store>
                <ext:Store ID="Store1" runat="server">
                    <Proxy>
                        <ext:AjaxProxy Json="true" Url="~/Pages/Handler.ashx">
                            <ActionMethods Read="POST" />
                            <Reader>
                                <ext:JsonReader />
                            </Reader>
                        </ext:AjaxProxy>
                    </Proxy>
                    <AutoLoadParams>
                        <ext:Parameter Name="lineID" Value="6" Mode="Raw" /> 
                    </AutoLoadParams>
                    <Model>
                        <ext:Model ID="Model1" runat="server">
                            <Fields>
                                <ext:ModelField Name="Common" />
                                <ext:ModelField Name="Botanical" />
                                <ext:ModelField Name="Light" />
                                <ext:ModelField Name="Price" Type="Float" />
                                <ext:ModelField Name="Availability" Type="Date" DateFormat="M$" />
                                <ext:ModelField Name="Indoor" Type="Boolean" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column ID="Column1" runat="server" Text="Common Name" DataIndex="Common" Sortable="true"
                        Flex="1" />
                    <ext:Column ID="Column2" runat="server" Text="Botanical" DataIndex="Botanical" Width="230" />
                    <ext:Column ID="Column3" runat="server" Text="Light" DataIndex="Light" Width="130" />
                    <ext:Column ID="Column4" runat="server" Text="Price" DataIndex="Price" Width="70"
                        Align="right" />
                    <ext:DateColumn ID="DateColumn1" runat="server" Text="Available" DataIndex="Availability"
                        Width="95" Format="yyyy-MM-dd" />
                    <ext:Column ID="Column5" runat="server" Text="Indoor?" DataIndex="Indoor" Width="55" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        <ext:Hidden ID="hdLineId" runat="server" Text="12" />
        </form>
    </body>
    </html>

    .Handler.ashx
    using System.Web;
    
    namespace Web.Pages
    {
        public class Handler : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                var id = context.Request["lineID"];
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
    Last edited by Daniil; Jun 25, 2012 at 7:24 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Just the Hidden field is not rendered yet when the AjaxProxy initiates its load request.

    Please define the Hidden field before the GridPanel.
    Last edited by Daniil; Jun 25, 2012 at 7:24 PM.
  3. #3
    Hmmmm, I didn't realize that what actually happens.

    It works now, thanks again.

    Quote Originally Posted by Daniil View Post
    Hi,

    Just the Hidden field is not rendered yet when the AjaxProxy initiates its load request.

    Please defined the Hidden field before the GridPanel.
  4. #4

    WebService Proxy (Handler) DOES NOT get my value when I pass it in from a <AutoLoadParams>

    On the change on EACH tab, my DirectMethod gets called "LoadActiveTab" which saves the value to the Hidden Field, but when it goes to the Handler the value of "id" below is null.

    var id = context.Request["lineID"];

    Code
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" TagPrefix="ext" Namespace="Ext.Net" %>
    <script runat="server">   
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                var lines = new List<string>() { "Line 1", "Line 2", "Line 3", "Line 4" };
                int i = 1;
                foreach (var line in lines)
                {
                    /* NEW Tab */
                    var tabStripItem = new Tab
                    {
                        TabID = @"_" + i,
                        Text = line,
                        ToolTip = line
                    };
    
                    TabStrip1.Items.Add(tabStripItem);
                    i++;
                }
                TabStrip1.Listeners.TabChange.Handler = "App.direct.LoadActiveTab(tab.id, tab.text);";
            }
        }
    
        [DirectMethod]
        public void LoadActiveTab(string id, string text)
        {
            var title = "ID #: " + id.Remove(0, 1);
            X.Msg.Notify(title, text).Show();
            hdLineId.Value = id.Remove(0, 1);
            Store1.Reload();
        }
    
    </script>
    <html>
    <head>
        <title>Example of Issue </title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Hidden ID="hdLineId" runat="server" />
        <ext:TabStrip ID="TabStrip1" runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" Title="Test" Frame="true" Height="300"
            Width="400">
            <Store>
                <ext:Store ID="Store1" runat="server">
                    <Proxy>
                        <ext:AjaxProxy Json="true" Url="~/Pages/Handler.ashx">
                            <ActionMethods Read="POST" />
                            <Reader>
                                <ext:JsonReader Root="data" />
                            </Reader>
                        </ext:AjaxProxy>
                    </Proxy>
                    <AutoLoadParams>
                        <ext:Parameter Name="lineID" Value="#{hdLineId}.getValue()" Mode="Raw" />
                    </AutoLoadParams>
                    <Model>
                        <ext:Model ID="Model1" runat="server">
                            <Fields>
                                <ext:ModelField Name="Common" />
                                <ext:ModelField Name="Botanical" />
                                <ext:ModelField Name="Light" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column runat="server" Text="Common Name" DataIndex="Common" Flex="1" />
                    <ext:Column runat="server" Text="Botanical" DataIndex="Botanical" />
                    <ext:Column runat="server" Text="Light" DataIndex="Light" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        </form>
    </body>
    </html>
    Handler
    using System.Web;
    
    namespace Web.Pages
    {
        public class Handler : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
    
                var id = context.Request["lineID"];
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
  5. #5
    Please set up:
    <Parameters>
        <ext:StoreParameter Name="lineID" Value="#{hdLineId}.getValue()" Mode="Raw" />
    </Parameters>
    instead of the AutoLoadParams section.

    The AutoLoadParams are used for the auto load request only.

    Also you might need to set up
    AutoLoad="false"
    for the Store, according to your scenario.
  6. #6
    Thanks, that works...

    Also thanks for the explaination, that helps also...

    Quote Originally Posted by Daniil View Post
    Please set up:
    <Parameters>
        <ext:StoreParameter Name="lineID" Value="#{hdLineId}.getValue()" Mode="Raw" />
    </Parameters>
    instead of the AutoLoadParams section.

    The AutoLoadParams are used for the auto load request only.

    Also you might need to set up
    AutoLoad="false"
    for the Store, according to your scenario.

Similar Threads

  1. Replies: 5
    Last Post: Nov 29, 2011, 8:22 PM
  2. Replies: 2
    Last Post: Oct 28, 2011, 7:44 AM
  3. [OPEN] Crashes, crashes, crashes...
    By swallace in forum Bugs
    Replies: 18
    Last Post: Sep 16, 2011, 7:17 AM
  4. [CLOSED] Hidden field problem
    By tdracz in forum 1.x Premium Help
    Replies: 4
    Last Post: Dec 12, 2008, 2:39 PM
  5. [CLOSED] How To Pass hidden value
    By Zarzand in forum 1.x Premium Help
    Replies: 7
    Last Post: Oct 31, 2008, 7:29 PM

Tags for this Thread

Posting Permissions