PDA

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



Fahd
Jun 25, 2012, 4:47 PM
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;
}
}
}
}

Daniil
Jun 25, 2012, 6:39 PM
Hi,

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

Please define the Hidden field before the GridPanel.

Fahd
Jun 25, 2012, 7:09 PM
Hmmmm, I didn't realize that what actually happens.

It works now, thanks again.


Hi,

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

Please defined the Hidden field before the GridPanel.

Fahd
Jun 26, 2012, 4:10 PM
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;
}
}
}
}

Daniil
Jun 26, 2012, 9:15 PM
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.

Fahd
Jun 26, 2012, 9:52 PM
Thanks, that works...

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


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.