473,320 Members | 2,054 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,320 software developers and data experts.

Using PartialCaching with dynamically added Webcontrols

DC
Hi,

we are dynamically adding webcontrols in a page like so:

Type t = Type.GetType("controls.namespace.control, controls.namespace",
false, true);
Control c = (Control)Activator.CreateInstance(t, true);
this.Controls.Add(c);

Now we would like to cache this webcontrol.

Using the same approach with user controls makes caching easier since
..LoadControl will return a PartialCachingControl which is "ready for
caching". Is there a similar approach for webcontrols?

When I simply cache control c in the example above I can reuse it, but
when multiple threads are adding such cached controls to their control
tree then the CreateChildControls process will throw exceptions (since
the same instance of one controls is being used simultaneously in
multiply control trees - I guess).

TIA for any idea!

Regards
DC

Nov 19 '05 #1
1 1469
DC
No clue, anyone? We can use some complicated stuff like below, but
using reflection seems to drag the performance down unnecessarily.

Here are two excellent articles on the topic:
http://weblogs.asp.net/dmarsh/archiv.../25/39793.aspx
http://weblogs.asp.net/dmarsh/archiv.../26/39957.aspx

I was hoping somebody here knows a snappier design.

public Control LoadWebControl(string typeName, string controlID)
{
Type controlType = Type.GetType(typeName, false, true);

PartialCachingAttribute cacheAttribute = new
PartialCachingAttribute(120, null, null, null, true);

PartialCachingControl cachedControl =
(PartialCachingControl)Activator.CreateInstance(
typeof(PartialCachingControl),
BindingFlags.NonPublic
| BindingFlags.Public
| BindingFlags.ExactBinding
| BindingFlags.Instance,
null,
new object[] {
controlType,
cacheAttribute,
controlID
},
CultureInfo.InvariantCulture
);
return cachedControl;
}

Nov 19 '05 #2

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

Similar topics

4
by: Bas Groeneveld | last post by:
I am developing an ASP.NET application part of which consists of a data entry wizard defined by entries in a data table - ie the controls on each page of the wizard are determined by definitions in...
4
by: sydney.luu | last post by:
Hello, I would greatly appreciate if someone can show me how to dynamically build a Repeater with unknown number of columns at design time. I have looked various threads in this newsgroup,...
1
by: Mike | last post by:
Hi, I am having troubles dealing with dynamically created WebControls. I have this HTML code: <form id="Form1" runat="server" method="post"> <table width="960" align="center"> <tr> <td...
0
by: DC | last post by:
Hi, thankfully this new method exists in the 2.0 Framework, in 1.1 it was more complicated to dynamically load a WebControl with PartialCaching. I did not try it, but I take it for granted that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.