473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to generate complex custom control

Hey everyone,

I am curious what the performance impact of a custom control would be if it
had a significant hierarchy of children. For example, 40 child controls, 5
levels deep, each control on average has 20 properties. What would be the
best way to implement such a thing?

The book I am reading uses templated controls and basically reconstructs the
entire hierarchy everytime page is accessed based on the tags in the .aspx
file, but books example only has 2 child controls. Would it make sence to
use xml configuration file instead of template elements? Would it be
possible to read the xml file once, build the hierarchy and then save it
somewhere, so that it is only regenerated when xml file changes? I was
thinking taking the root element and storing it in application cache, or
even serializing it to disk, but I am not sure if controls are allowed to be
reused for subsequent requests.

So anyone know the proper way such situation would be handled?

Oh yeah, I was thinking placing the whole thing into a user control and
making it cachable, but control would still be regenerated if it has to
process post-back events, right?

Thanks for any info

-- Dennis
Nov 18 '05 #1
3 1907
Hi Dennis,

From your description, you're wanting do generate a complex custom control
which has huge amount of sub elements and also deep hierarchy. Since
normally all the server controls on the page will be reconstrucuted when
the page is requested and loaded on the serverside, you're wondering some
means to improve the performance, yes?

I think the behavior that a server control is recontructed at serverside
when processing its contaier page is unavoidable. Everytime the page is
processing on the severside, it'll first reconstructor the Control
hierarchy and mapping their viewstates to them(if is post back). If you
want to avoid this, one way is to use the Cache function in ASP.NET, and I
think the means that use xml configuration file to store the controls'
strucutre info and restructure the control whenever the file is modifed you
mentiond is reasonable. In ASP.NET 's serverside cache feature, there is
one means to help cache the page's output depend on a file on the
serverside , the page will be construcuted( all its controls) the first
time it is request , after that if we request the page again, the page's
ouput will be the plain html values which is output the first. And this
cache will remain until the dependent file is modified. For detailed info,
you can view the following reference in MSDN:

#ASP.NET Caching Features
http://msdn.microsoft.com/library/en...achingfeatures
..asp?frame=true

#@Caching Page Output with File Dependencies
http://msdn.microsoft.com/library/en...ingpageoutputw
ithfiledependencies.asp?frame=true

Also, if you don't want to cache a whole page. I think you can manually
implement the control's file denpendent caching in your control's
construcut code. For example, you can generate the control's structure and
render it out the first time and store the output in the Application.Cache,
and the cahe is file dependent, then the next time the control will check
the applcation cache, if exist retrieve the cache and output it rather than
reconstrucure the whole control. How do you think of this? Also, I think
we may wait for some one else's suggestions. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Nov 18 '05 #2
Hey Steven,

Thanks for the response, I think I will end up some sort of variation
of what you suggested.

But what I was really curious about if instead of caching text
(control output as HTML), can I build the control object tree once and
then take the top object and put it into application cache. I've
tried something similar with a drop-down box that I initialized by
reading an XML file and it seems to be working, but I don't know if it
is legal, or what complication I could expect.

Actually as I am writing this, I just thought of one: if the control
hierarchy is shared and 2 users postback at the same time, the same
controls will probably be initialized with postback data, if there is
postback data. So that probably won't be good. But what if there is
no postback data and all control data members are common for all users
(and maybe changed at some point at the application level), then maybe
it is legal.

What do you think?

Another question to you or anyone who knows this. You probably can't
cache pure text HTML output if control has to process post-backs
because if you use the cache, objects don't get instantiated and
therefore they can't process the postbacks (or events), right?

Thanks,

-- Dennis
v-******@online.microsoft.com (Steven Cheng[MSFT]) wrote in message news:<nm**************@cpmsftngxa10.phx.gbl>...
Hi Dennis,

From your description, you're wanting do generate a complex custom control
which has huge amount of sub elements and also deep hierarchy. Since
normally all the server controls on the page will be reconstrucuted when
the page is requested and loaded on the serverside, you're wondering some
means to improve the performance, yes?

I think the behavior that a server control is recontructed at serverside
when processing its contaier page is unavoidable. Everytime the page is
processing on the severside, it'll first reconstructor the Control
hierarchy and mapping their viewstates to them(if is post back). If you
want to avoid this, one way is to use the Cache function in ASP.NET, and I
think the means that use xml configuration file to store the controls'
strucutre info and restructure the control whenever the file is modifed you
mentiond is reasonable. In ASP.NET 's serverside cache feature, there is
one means to help cache the page's output depend on a file on the
serverside , the page will be construcuted( all its controls) the first
time it is request , after that if we request the page again, the page's
ouput will be the plain html values which is output the first. And this
cache will remain until the dependent file is modified. For detailed info,
you can view the following reference in MSDN:

#ASP.NET Caching Features
http://msdn.microsoft.com/library/en...achingfeatures
.asp?frame=true

#@Caching Page Output with File Dependencies
http://msdn.microsoft.com/library/en...ingpageoutputw
ithfiledependencies.asp?frame=true

Also, if you don't want to cache a whole page. I think you can manually
implement the control's file denpendent caching in your control's
construcut code. For example, you can generate the control's structure and
render it out the first time and store the output in the Application.Cache,
and the cahe is file dependent, then the next time the control will check
the applcation cache, if exist retrieve the cache and output it rather than
reconstrucure the whole control. How do you think of this? Also, I think
we may wait for some one else's suggestions. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
Hi Dennis,

Well, I agree with you on cached the control structure instances rather
than plain html string. Also that'll be ok if the control's structure is
shared by all users and won't be critical on personalization issues. In
addtion, as for the following issues on post back when caching the
htmloutput:
=========================
Another question to you or anyone who knows this. You probably can't
cache pure text HTML output if control has to process post-backs
because if you use the cache, objects don't get instantiated and
therefore they can't process the postbacks (or events), right?
=========================

Yes, this will cause the post back not work. I just forget this problem.
Thanks for your noticing.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lut | last post by:
Hey, I made a custom usercontrol (Custom listview) in the Control Library. Now I want in the properties of design a property 'Sort'. (That is not a problem to do that) But, when it is Yes...
3
by: Dennis M | last post by:
Hey everyone, I am curious what the performance impact of a custom control would be if it had a significant hierarchy of children. For example, 40 child controls, 5 levels deep, each control on...
1
by: Dot net work | last post by:
Hello. I have an interesting data binding scenario: I have a repeater control. It repeats a typical custom web user control. I also have a collection object, and each collection element...
1
by: A Traveler | last post by:
Hello, i am having this problem. The exact error message is: "Unable to generate code for a value of type 'System.Web.UI.Page'. This error occurred while trying to generate the property value for...
5
by: Trail Monster | last post by:
Ok, I've been searching the net now for several days and can't find how to do this anywhere. Version: VS 2005 Professional Release, 2.0 Framework Background: I have a complex business object...
3
by: Bernie Yaeger | last post by:
I'm trying to create a custom control that has 2 listviews, in view smallicon. I'm using these with code that makes them drag/drop controls, so what I am after is a control that does drag/drop...
1
by: Jeremy Chapman | last post by:
I have a property will an array of webcontrols. The control features a custom property editor which can add and remove web controls to the array, but how do I persist the informtion by...
0
by: Iain | last post by:
Can I apologise for the lengthy nature of this post. The scenario is complicated (though I hope the solution is not!) basically, I've got a custom template control which binds itself to a tree...
6
by: junk | last post by:
Senerio: I have a custom user control which contains two control arrays. The user control has a group box in which the two control arrays are dynamically built. The two control arrays are...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.