Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Miles Thompson #1
compilation and/or getting to the "ASP" assembly
Hi !
I'm trying to optimize a slow page.
The page contains multiple instances of the same UserControl, and the
profiler is telling me that the following line is slow ..
CSWWItem myWWItem = (CSWWItem) LoadControl("../CSControls/CSWWItem.ascx");
It occurs to me that maybe LoadControl is recompiling the ascx page every
time its called. If so, my question becomes.. is there a way to manually
compile and then create instances of the controls from the compiled
version??
Thats the short version, heres the longer one, with more details.
The thing is I have a user control (which uses code behind) with an ascx
file that starts off like this.
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="CSWWItem.ascx.cs"
ClassName="CSWWItemControl"
Inherits="CreditSights.CMS.CSControls.CSWWItem" %>
As I understand it, when ASP.NET needs to load this user control it compiles
the ascx code and creates a class, with class name "ASP.CSWWItemControl" and
presumably this goes into some dynamically created "ASP" assembly somewhere.
(If I don't specify the classname attribute, it creates an instance of type
"ASP.CSWWItem_ascx").
In other words if I do this..
object nextItem = LoadControl("../CSControls/CSWWItem.ascx");
...then the instance "nextItem" is of type "ASP.CSWWItemControl".
What I would rather do is something like this..
ASP.CSWWItemInclude nextItem = new ASP.CSWWItemControl();
nextItem.InitializeAsUserControl();
nextItem.Property1 = "value1";
Page.Controls.Add(nextItem);
At least, I guess that then I would *know* that it was only compiled once,
and therefore, hopefully faster than the LoadControl(".") way.
Problem with that is, I can't add a reference in the code behind to the
"ASP" assembly.. I mean I don't even know where it is, and have a feeling
that I shouldn't do that anyway.
Alternatively is there a way to compile my own ascx file into a type that I
can then "CreateInstance" on? Anybody know how to do that? I'm willing to
sacrifice auto-compilation for the speed benefit in this case.
Any suggestions much appreciated. Thanks in advance !
Miles Thompson Guest
-
Compilation errors using #include "PDSReadProcs.h"
Hi, In VS 2005 console exe application vc++ I get 100+ errors on including:- #include "PDSReadProcs.h" Errors as:-... -
Assembly acessing StrongNamed assembly getting "Access Denied" intermitently
I have an ASP.NET application that is using a code library our development team uses. The code library is a few web controls in a Strong Named... -
HELP! - "The WSIntranet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=24410d33c1a2222e assembly specified in a Register directive of this page could not be found"
Hi, I am just building my first webpart. It worked fine when I just had output.write("hello"). As soon as I try and do this: SPWeb... -
"Start" "Program" "Menu" list is empty
For what ever reason my list of installed programs in my "Start" "Programs" menu is empty. Anyone know how to restore the list. Thanks for your... -
Configuration Error (<add assembly="*"/>)
I had a similar problem: For me the problem would arise the 2nd or 3rd time I would compile the web app after rebooting my machine. I could never...



Reply With Quote

