PDA

View Full Version : [CLOSED] Is there any way to render controls without using .aspx or .ascx loading?



jamesand
Jan 17, 2014, 11:17 AM

Daniil
Jan 17, 2014, 2:47 PM
Hi @jamesand,

Please investigate these examples:
http://examples2.ext.net/#/search/template+widget

Probably, it is what you are looking for.

geoffrey.mcgill
Jan 17, 2014, 3:16 PM
Dynamic rendering could be an option for you too:

http://examples2.ext.net/#/search/xrender

jamesand
Jan 20, 2014, 9:21 AM
Thank you Daniil and Geoffrey, but that's not the idea. I already checked those possibilities, but both use user controls, which we want to avoid here.

We have a Portlet, and we want to render the GridPanel when we press one button, but without using user controls. Is it possible?

Daniil
Jan 20, 2014, 11:08 AM
Both the approaches that we demonstrated don't require a user control to be used.

There is no user control in this example:
http://examples2.ext.net/#/Miscellaneous/Template_Widget/Overview/

And no user control here as well:
http://examples2.ext.net/#/XRender/Basic/New_Window/

jamesand
Jan 21, 2014, 8:30 AM
Both the approaches that we demonstrated don't require a user control to be used.

There is no user control in this example:
http://examples2.ext.net/#/Miscellaneous/Template_Widget/Overview/

And no user control here as well:
http://examples2.ext.net/#/XRender/Basic/New_Window/

Yes I know, but those examples creates controls dinamically, and that's not our way in this case.

In my first example, the question would have been: "Is there any way to render controls without using .aspx or .ascx loading and without creating controls dinamically?"

It may be a non-sense question, because if the code is there, it has to be rendered.

Thank you and I assume it is not possible.

Regards,

Daniil
Jan 21, 2014, 9:39 AM
Yes I know, but those examples creates controls dinamically, and that's not our way in this case.

Probably, there is some misunderstanding between us.

Again, this example:
http://examples2.ext.net/#/Miscellaneous/Template_Widget/Overview/

Please clarify what do you mean by "those examples create controls dynamically" according to the example above? Do you mean this call?

App.getMessageWindow().show();

jamesand
Jan 21, 2014, 11:07 AM

Daniil
Jan 21, 2014, 11:38 AM
Well, the TemplateWidget property is defined in the BaseControl class, the base class for all the components which can be rendered to the page.

So, it can be used for a GridPanel as well. The only restriction - you cannot put it to an Items collection.

Example

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

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

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { "test", "test" },
new object[] { "test", "test" },
new object[] { "test", "test" }
};
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Render GridPanel" Handler="App.Panel1.add(App.getGridPanel1());" />

<ext:GridPanel ID="GridPanel1" runat="server" TemplateWidget="true">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test 1" DataIndex="test1" />
<ext:Column runat="server" Text="Test 2" DataIndex="test2" />
</Columns>
</ColumnModel>
</ext:GridPanel>

<ext:Panel
ID="Panel1"
runat="server"
Title="GridPanel Holder"
Width="400"
Height="400"
Layout="FitLayout" />
</form>
</body>
</html>

jamesand
Jan 21, 2014, 12:25 PM
Well, the TemplateWidget property is defined in the BaseControl class, the base class for all the components which can be rendered to the page.

So, it can be used for a GridPanel as well. The only restriction - you cannot put it to an Items collection.

Hi Daniil, that doesn't suit our needs ;)

Thank you anyway for your help again.

Daniil
Jan 21, 2014, 12:39 PM
Please clarify why? Because of this restriction?

The only restriction - you cannot put it to an Items collection.

jamesand
Jan 21, 2014, 1:04 PM
We've been investigating an it looks good! But we have to put the gridpanel inside <HtmlBin>, if not the gridpanel is rendered...

Daniil
Jan 21, 2014, 1:18 PM
Please clarify what do you mean by "rendered"? The fact that it appears in the Page Sources?

If so, then there is no way to avoid to achieve your requirement not to use .aspx or .ascx.

Even if you put it to HtmlBin, it still appears in the Page Sources. So, I don't quite understand what you mean.

But a component with TemplateWidget="true" is not rendered (well, "painted") in the browser. No DOM elements are created. So, if your goal is performance, then it is really OK to have it in the Page Sources and render to the browser on demand.

jamesand
Jan 21, 2014, 1:25 PM
But a component with TemplateWidget="true" is not rendered (well, "painted") in the browser. No DOM elements are created. So, if your goal is performance, then it is really OK to have it in the Page Sources and render to the browser on demand.

That's the main point yes. So if no DOM elements are created, this fully fill our needs :)

Thank you.

Daniil
Jan 21, 2014, 1:30 PM
Yes, no DOM elements are created until a template function call.