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

Compilation of UserControls

In several of my UserControls I add properties. If I access these properties
in the CodeBehind of the pages that use the controls, I recieve an error
when compiling. The reason for this is because the compiler tries to compile
the pages that use the UserControls before compiling the UserControls, and
therefore does not know that the property exists when compiling. The only
way around this that I have found is to use the CType() function as follows:

CType(MyUserCtrlInstance, MyUserCtrlClass).AddedProperty

instead of:

MyUserCtrlInstance.AddedProperty

Even though this works, it is a lot of extra CType() functions that would
not be necessary if I could simply have my UserControls compiled first. Is
there any way to make the compiler look at my UserControls first without
putting them in a separate assembly? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Jan 18 '07 #1
4 1230
Well, if the UserControls are not compiled (or at least resolved properly),
the classes that depend on them would not compile.

And btw, what is the datatype of MyUserCtrlInstance? Is it simply
UserControl --- if so, yes, you are already in trouble.

--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-----------------------------------------
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:uI**************@TK2MSFTNGP04.phx.gbl...
In several of my UserControls I add properties. If I access these
properties in the CodeBehind of the pages that use the controls, I recieve
an error when compiling. The reason for this is because the compiler tries
to compile the pages that use the UserControls before compiling the
UserControls, and therefore does not know that the property exists when
compiling. The only way around this that I have found is to use the
CType() function as follows:

CType(MyUserCtrlInstance, MyUserCtrlClass).AddedProperty

instead of:

MyUserCtrlInstance.AddedProperty

Even though this works, it is a lot of extra CType() functions that would
not be necessary if I could simply have my UserControls compiled first. Is
there any way to make the compiler look at my UserControls first without
putting them in a separate assembly? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Jan 18 '07 #2
Out of curiuosity nathan, What langauge are you using
C#? or VB.NET
And what version of .NET are you using? 1.x or 2.0 ?
I put controls in my App_Code all the time for quicker testing and
development and this usually works fine for me.

"Nathan Sokalski" wrote:
In several of my UserControls I add properties. If I access these properties
in the CodeBehind of the pages that use the controls, I recieve an error
when compiling. The reason for this is because the compiler tries to compile
the pages that use the UserControls before compiling the UserControls, and
therefore does not know that the property exists when compiling. The only
way around this that I have found is to use the CType() function as follows:

CType(MyUserCtrlInstance, MyUserCtrlClass).AddedProperty

instead of:

MyUserCtrlInstance.AddedProperty

Even though this works, it is a lot of extra CType() functions that would
not be necessary if I could simply have my UserControls compiled first. Is
there any way to make the compiler look at my UserControls first without
putting them in a separate assembly? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Jan 20 '07 #3

Nathan Sokalski wrote:
In several of my UserControls I add properties. If I access these properties
in the CodeBehind of the pages that use the controls, I recieve an error
when compiling. The reason for this is because the compiler tries to compile
the pages that use the UserControls before compiling the UserControls, and
therefore does not know that the property exists when compiling. The only
way around this that I have found is to use the CType() function as follows:

CType(MyUserCtrlInstance, MyUserCtrlClass).AddedProperty

instead of:

MyUserCtrlInstance.AddedProperty

Even though this works, it is a lot of extra CType() functions that would
not be necessary if I could simply have my UserControls compiled first. Is
there any way to make the compiler look at my UserControls first without
putting them in a separate assembly? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Nathan, have you tried the Build | Rebuild Web Site menu item in VS.NET
2005? I was having the same problem. However when you rebuild the
entire web site it then compiles everything and you can pick up the
properties.

Hope this helps,

Corey

Jan 20 '07 #4
I do use Rebuild in VS.NET 2005, but I still receive the error. I have a
feeling that it is possible that my problem might be in that there is an
error somewhere else that is preventing the controls from compiling, since
it seems like this happens sometimes and not others. However, I am not sure
how to find where the other error is (if my suspicion is true) since it does
not list it in the compilation errors because it does not get to that point
in the compilation.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Corey B" <co***********@gmail.comwrote in message
news:11**********************@s34g2000cwa.googlegr oups.com...
>
Nathan Sokalski wrote:
>In several of my UserControls I add properties. If I access these
properties
in the CodeBehind of the pages that use the controls, I recieve an error
when compiling. The reason for this is because the compiler tries to
compile
the pages that use the UserControls before compiling the UserControls,
and
therefore does not know that the property exists when compiling. The only
way around this that I have found is to use the CType() function as
follows:

CType(MyUserCtrlInstance, MyUserCtrlClass).AddedProperty

instead of:

MyUserCtrlInstance.AddedProperty

Even though this works, it is a lot of extra CType() functions that would
not be necessary if I could simply have my UserControls compiled first.
Is
there any way to make the compiler look at my UserControls first without
putting them in a separate assembly? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Nathan, have you tried the Build | Rebuild Web Site menu item in VS.NET
2005? I was having the same problem. However when you rebuild the
entire web site it then compiles everything and you can pick up the
properties.

Hope this helps,

Corey

Jan 21 '07 #5

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

Similar topics

1
by: Anders Borum | last post by:
Hello! I was wondering if I am the only person missing the option of outputting a single dll for a website (just like the good old v1.1 compilation model)? What I'm looking for is the ASP.NET...
5
by: Nathan Sokalski | last post by:
In several of my UserControls I add properties. If I access these properties in the CodeBehind of the pages that use the controls, I recieve an error when compiling. The reason for this is because...
4
by: Nathan Sokalski | last post by:
In several of my UserControls I add properties. If I access these properties in the CodeBehind of the pages that use the controls, I recieve an error when compiling. The reason for this is because...
0
by: hirebrian | last post by:
If you run accross the error message: "Element '%' is not a known element. This can occur if there is a compilation error in the Web site" where '%' is the value of the tagName attribute on a...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.