PDA

View Full Version : [CLOSED] AutoLoad Parameter [ChangeLog]



Daly_AF
Apr 09, 2012, 2:21 PM
In Ext.net 1.2 and 1.3 this sample works fine


<ext:Panel ID="_pnl" runat="server" Flex="1" Layout="Fit" Width="250" Region="West"
Collapsible="true">
<AutoLoad Url="/ViewEngine/LoadWestMenu">
<Params>
<ext:Parameter Name="containerID" Value="#{_pnl}" Mode="Value" />
</Params>
</AutoLoad>
</ext:Panel>

When trying to upgrade to Ext.net 2.0


<ext:Panel ID="_pnl" runat="server" Flex="1" Layout="Fit" Width="250" Region="West"
Collapsible="true">
<Loader Url="/ViewEngine/LoadWestMenu" runat="server" Mode="Component">
<AjaxOptions>
<Params>
<ext:Parameter Name="containerID" Value="#{_pnl}" Mode="Value" />
</Params>
</AjaxOptions>
</Loader>
</ext:Panel>

In the ?LoadWestMenu? action the containerID parameter is null.
Any suggestion please?

Daniil
Apr 09, 2012, 3:33 PM
Hi,

This is how you can load a component with

Mode="Component"

Example View

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!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>Ext.Net.MVC v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Panel
runat="server"
Width="250"
Height="250"
Layout="Fit">
<Loader
runat="server"
Url="/Test/Load"
Mode="Component" />
</ext:Panel>
</body>
</html>

Example Controller Action

public void Load()
{
Panel p = new Panel()
{
Html = "Hello World!"
};

ComponentLoader.Render(p);
}

Vladimir
Apr 09, 2012, 3:38 PM
Please update from SVN and use Params of Loader instead AjaxOptions params


<Loader Url="/ViewEngine/LoadWestMenu" runat="server" Mode="Component">
<Params>
<ext:Parameter Name="containerID" Value="#{_pnl}" Mode="Value" />
</Params>
</Loader>

Daly_AF
Apr 09, 2012, 5:07 PM
Please update from SVN and use Params of Loader instead AjaxOptions params


<Loader Url="/ViewEngine/LoadWestMenu" runat="server" Mode="Component">
<Params>
<ext:Parameter Name="containerID" Value="#{_pnl}" Mode="Value" />
</Params>
</Loader>


Thanks Vladimir, but the parameter is always null
this is the Action code


public ContentResult LoadWestMenu(String containerID)
{
var contentResult = new ContentResult();
contentResult.Content = string.Format("<script>{0}</script>", _serviceWestMenu.CreateWestMenu()
.ToScript(RenderMode.AddTo, containerID));
return contentResult;
}

Daly_AF
Apr 09, 2012, 5:15 PM
Hi,

This is how you can load a component with

Mode="Component"

Example View

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!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>Ext.Net.MVC v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Panel
runat="server"
Width="250"
Height="250"
Layout="Fit">
<Loader
runat="server"
Url="/Test/Load"
Mode="Component" />
</ext:Panel>
</body>
</html>

Example Controller Action

public void Load()
{
Panel p = new Panel()
{
Html = "Hello World!"
};

ComponentLoader.Render(p);
}

This method works fine but we need to pass parameter into the action url otherwise we need to implement an Action for each loader.

Daniil
Apr 09, 2012, 5:34 PM
Thanks Vladimir, but the parameter is always null
this is the Action code


public ContentResult LoadWestMenu(String containerID)
{
var contentResult = new ContentResult();
contentResult.Content = string.Format("<script>{0}</script>", _serviceWestMenu.CreateWestMenu()
.ToScript(RenderMode.AddTo, containerID));
return contentResult;
}

The following works for me.

Example View

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!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>Ext.Net.MVC v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Panel
ID="Panel1"
runat="server"
Width="250"
Height="250"
Layout="Fit">
<Loader
runat="server"
Url="/Test/Load"
Mode="Html">
<Params>
<ext:Parameter Name="containerId" Value="#{Panel1}" Mode="Value" />
</Params>
<Listeners>
<Load Handler="eval(response.responseText);" />
</Listeners>
</Loader>
</ext:Panel>
</body>
</html>

Example Controller Action

public ContentResult Load(String containerId)
{
var contentResult = new ContentResult();
contentResult.Content = new Panel() { Html = "Hello World" }.ToScript(RenderMode.AddTo, containerId);
return contentResult;
}

Daniil
Apr 09, 2012, 5:56 PM
This method works fine but we need to pass parameter into the action url otherwise we need to implement an Action for each loader.

I don't think you will need to implement an action for each loader.

Example View

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!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>Ext.Net.MVC v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Panel
ID="Panel1"
runat="server"
Width="250"
Height="250"
Layout="Fit">
<Loader
runat="server"
Url="/Test/Load"
Mode="Component">
<Params>
<ext:Parameter Name="containerId" Value="this.target.id" Mode="Raw" />
</Params>
</Loader>
</ext:Panel>

<ext:Panel
ID="Panel2"
runat="server"
Width="250"
Height="250"
Layout="Fit">
<Loader
runat="server"
Url="/Test/Load"
Mode="Component">
<Params>
<ext:Parameter Name="containerId" Value="this.target.id" Mode="Raw" />
</Params>
</Loader>
</ext:Panel>
</body>
</html>

Example Controller Action

public ActionResult Load(string containerId)
{
Panel p = new Panel()
{
Html = containerId
};

ContentResult r = new ContentResult();
r.Content = ComponentLoader.ToJson(p);

return r;
}

Daly_AF
Apr 10, 2012, 10:40 AM
The following works for me.

Example View

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!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>Ext.Net.MVC v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Panel
ID="Panel1"
runat="server"
Width="250"
Height="250"
Layout="Fit">
<Loader
runat="server"
Url="/Test/Load"
Mode="Html">
<Params>
<ext:Parameter Name="containerId" Value="#{Panel1}" Mode="Value" />
</Params>
<Listeners>
<Load Handler="eval(response.responseText);" />
</Listeners>
</Loader>
</ext:Panel>
</body>
</html>

Example Controller Action

public ContentResult Load(String containerId)
{
var contentResult = new ContentResult();
contentResult.Content = new Panel() { Html = "Hello World" }.ToScript(RenderMode.AddTo, containerId);
return contentResult;
}

Hi Daniil,
When I add the Load listener, in firebug console I have this error


missing } in XML expression
...rm/', icon : el.iconCls });}}}},{iconCls:"#Information",text:"About",listeners:{...
and the rendering of the component does not succeed.

Daly_AF
Apr 10, 2012, 10:42 AM
I don't think you will need to implement an action for each loader.

Example View

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!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>Ext.Net.MVC v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Panel
ID="Panel1"
runat="server"
Width="250"
Height="250"
Layout="Fit">
<Loader
runat="server"
Url="/Test/Load"
Mode="Component">
<Params>
<ext:Parameter Name="containerId" Value="this.target.id" Mode="Raw" />
</Params>
</Loader>
</ext:Panel>

<ext:Panel
ID="Panel2"
runat="server"
Width="250"
Height="250"
Layout="Fit">
<Loader
runat="server"
Url="/Test/Load"
Mode="Component">
<Params>
<ext:Parameter Name="containerId" Value="this.target.id" Mode="Raw" />
</Params>
</Loader>
</ext:Panel>
</body>
</html>

Example Controller Action

public ActionResult Load(string containerId)
{
Panel p = new Panel()
{
Html = containerId
};

ContentResult r = new ContentResult();
r.Content = ComponentLoader.ToJson(p);

return r;
}

In this sample, It works fine.

Daniil
Apr 10, 2012, 10:51 AM
When I add the Load listener, in firebug console I have this error


missing } in XML expression
...rm/', icon : el.iconCls });}}}},{iconCls:"#Information",text:"About",listeners:{...
and the rendering of the component does not succeed.

Did you update from SVN? It has been fixed recently.
http://forums.ext.net/showthread.php?18300&p=78952&viewfull=1#post78952

Daly_AF
Apr 10, 2012, 11:14 AM
Did you update from SVN? It has been fixed recently.
http://forums.ext.net/showthread.php?18300&p=78952&viewfull=1#post78952

Yes I did the update yesterday after noon.

Daniil
Apr 10, 2012, 11:17 AM
Please ensure there is the new (updated) dll in your local project.

I was unable to reproduce the problem with the last Ext.NET sources.

Daly_AF
Apr 10, 2012, 11:27 AM
Please give me the svn link to download the latest version because I'm working with Ext.NET 2.0 Beta Dll's.

Daniil
Apr 10, 2012, 11:30 AM
This link:
http://svn.ext.net/premium/branches/2.0/Ext.Net/

Daly_AF
Apr 10, 2012, 12:07 PM
Hi Daniil,

I do the last update, generated DLL version is 2.0.4483.23038 and the same error occurs.

Daniil
Apr 10, 2012, 12:17 PM
Are you sure the new DLL is affected to your project?

I've checked again - it works correctly on my side.

Please try with:

<ext:Parameter Name="containerId" Value="Panel1" Mode="Value" />
instead of

<ext:Parameter Name="containerId" Value="#{Panel1}" Mode="Value" />

Does it work? If yes, it means the old dll is used.

Daly_AF
Apr 10, 2012, 2:04 PM
It doesn't work.
this is a simple code to reproduce the problem

Controller Action

public ContentResult Load(String containerID)
{
var contentResult = new ContentResult();
Panel p = new Panel("Title");
p.Height = 200;
p.Html = "Hello World";
contentResult.Content = string.Format("<script>{0}</script>", p
.ToScript(RenderMode.AddTo, containerID));
return contentResult;

}


<ext:Panel ID="_pnl" runat="server" Flex="1" Layout="Fit" Width="250" Region="West" Height="300"
Collapsible="true">
<Loader Url="/ViewEngine/Load" runat="server" Mode="Html">
<Params>
<ext:Parameter Name="containerID" Value="_pnl" Mode="Value" />
</Params>
<Listeners>
<Load Handler="eval(response.responseText);"/>
</Listeners>
</Loader>
</ext:Panel>

Daniil
Apr 10, 2012, 2:16 PM
Well, your controller action code differs from the code in my example. The difference causes the error.

Anyways, we would recommend to use the example with

Mode="Component"

Daly_AF
Apr 10, 2012, 2:29 PM
Thanks Danil, it works.