469,920 Members | 2,363 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,920 developers. It's quick & easy.

Loading Controls Dynamically

Hi -

I am seeing some performance degradation when I am loading a control
dynamically onto a page with multiple other dynamical controls using
Page.LoadControl versus dragging and dropping it onto an individual page.

Page1.aspx.cs
UserControl uc = Page.LoadControl("../UserControls/UserControl1.ascx")

Page2.aspx
<%@ Register TagPrefix="uc1" TagName="UserControl1"
Src="../UserControls/UserControl1.ascx" %>
<HTML>
<HEAD></HEAD>
<BODY>
<form id="StrategicReports" method="post" runat="server">
<uc1:UserControl1 id="UI1" runat="server"></uc1:UserControl1>
</form>
</BODY>
</HTML>

Page2.aspx renders the control much faster than Page1.aspx. Page1.aspx does
do some work in trying to identify which control to load but this still does
not account for the performance hit. Any ideas what is going on here? Is
there some other way to dynamically load the user control, say by adding a
"Reference" in Page1.aspx? Any help will be greatly appreciated.

Thanks in advance.
Kan
Nov 18 '05 #1
1 1280
This shouldn't be a surprise...one is loading the control at runtime, the
other at compile time. It's slower, but it shouldn't be hugely slower (ie,
only noticable when profiling).

Server controls load considerably faster than user controls...but that's
really your only option..

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"kanones" <ka*****@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com...
Hi -

I am seeing some performance degradation when I am loading a control
dynamically onto a page with multiple other dynamical controls using
Page.LoadControl versus dragging and dropping it onto an individual page.

Page1.aspx.cs
UserControl uc = Page.LoadControl("../UserControls/UserControl1.ascx")

Page2.aspx
<%@ Register TagPrefix="uc1" TagName="UserControl1"
Src="../UserControls/UserControl1.ascx" %>
<HTML>
<HEAD></HEAD>
<BODY>
<form id="StrategicReports" method="post" runat="server">
<uc1:UserControl1 id="UI1" runat="server"></uc1:UserControl1>
</form>
</BODY>
</HTML>

Page2.aspx renders the control much faster than Page1.aspx. Page1.aspx does do some work in trying to identify which control to load but this still does not account for the performance hit. Any ideas what is going on here? Is
there some other way to dynamically load the user control, say by adding a
"Reference" in Page1.aspx? Any help will be greatly appreciated.

Thanks in advance.
Kan

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Peter Zuber | last post: by
2 posts views Thread by macca | last post: by
1 post views Thread by Sundaresan | last post: by
1 post views Thread by Jill Graham | last post: by
3 posts views Thread by supvine | last post: by
2 posts views Thread by Raymond Du | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.