Hello,
I have a user control that has one .cs file, with several .ascx files
that call it. The reason for this is that I can pick whichever of the
..ascx files I want (based on a site owner setting), and I know the
code-behind is the same in all cases. That way the .ascx file can be
picked dynamically, allowing the appearance of the page to be changed
based on a user setting.
This was working fine in 1.1, but had the code-behind compiled into a
DLL. I'm trying to convert the user control(s) to use the new 2.0
code-behind model, and would like to avoid having to compile the DLL
each time.
The page that uses the control has a placeholder called
plcProductDetails, and has code like...
string fileName = "ShowProductStyle1.ascx"; // normally from user
setting
Control ctlShowProduct = LoadControl(fileName);
((ShowProduct)ctlShowProduct).DisplayProduct();
plcProductDetails.Controls.Add(ctlShowProduct);
Now this worked fine when using the old 1.1 code-behind model. I could
compile ShowProduct.dll on its own and the code above would find it OK.
Now I have deleted the DLL, and changed the top of each of the .ascx
files to look like...
<%@ Control CodeFile="ShowProduct.cs" Inherits="ShowProduct" %>
and the top of the code-behind file looks like...
// various "using" statements omitted for clarity
public partial class ShowProduct : UserControl {
If I try to load the page now, I get an error...
"CS0246: The type or namespace name 'ShowProduct' could not be found"
on the line...
((ShowProduct)ctlShowProduct).DisplayProduct();
I don't know how to get around this. When LoadControl was called, it
referenced the .ascx file, and that referenced the code-behind file that
contains the class definition for ShowProduct. Why then can't the
framework find the class?
I hope this is clear. I'm really lost here and would appreciate any clue
as to how I am supposed to do this. The weird thing is that I tried
creating a user control in VWD, and I could have two .ascx files
referencing the same .cs file and they both work fine without me needing
to compile anything. I'm obviously doing something wrong, but I can't
see what.
TIA
--
Alan Silver
(anything added below this line is nothing to do with me) 2 1241
you can not share partial classes between asxc. you need to stick to your
old coding style. move the common code to a file in the app_code dir, so all
pages can see it. as you will not be able to use a partial classes, turn
autowireup events off, and use the 1.1 coding style.
you would proably be better off switching to themes to change the look.
-- bruce (sqlwork.com)
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:jr**************@nospamthankyou.spam... Hello,
I have a user control that has one .cs file, with several .ascx files that call it. The reason for this is that I can pick whichever of the .ascx files I want (based on a site owner setting), and I know the code-behind is the same in all cases. That way the .ascx file can be picked dynamically, allowing the appearance of the page to be changed based on a user setting.
This was working fine in 1.1, but had the code-behind compiled into a DLL. I'm trying to convert the user control(s) to use the new 2.0 code-behind model, and would like to avoid having to compile the DLL each time.
The page that uses the control has a placeholder called plcProductDetails, and has code like...
string fileName = "ShowProductStyle1.ascx"; // normally from user setting Control ctlShowProduct = LoadControl(fileName); ((ShowProduct)ctlShowProduct).DisplayProduct(); plcProductDetails.Controls.Add(ctlShowProduct);
Now this worked fine when using the old 1.1 code-behind model. I could compile ShowProduct.dll on its own and the code above would find it OK.
Now I have deleted the DLL, and changed the top of each of the .ascx files to look like...
<%@ Control CodeFile="ShowProduct.cs" Inherits="ShowProduct" %>
and the top of the code-behind file looks like...
// various "using" statements omitted for clarity public partial class ShowProduct : UserControl {
If I try to load the page now, I get an error...
"CS0246: The type or namespace name 'ShowProduct' could not be found"
on the line...
((ShowProduct)ctlShowProduct).DisplayProduct();
I don't know how to get around this. When LoadControl was called, it referenced the .ascx file, and that referenced the code-behind file that contains the class definition for ShowProduct. Why then can't the framework find the class?
I hope this is clear. I'm really lost here and would appreciate any clue as to how I am supposed to do this. The weird thing is that I tried creating a user control in VWD, and I could have two .ascx files referencing the same .cs file and they both work fine without me needing to compile anything. I'm obviously doing something wrong, but I can't see what.
TIA
-- Alan Silver (anything added below this line is nothing to do with me)
>you can not share partial classes between asxc. you need to stick to your old coding style. move the common code to a file in the app_code dir, so all pages can see it. as you will not be able to use a partial classes, turn autowireup events off, and use the 1.1 coding style.
OK, thanks. At least I know I wasn't doing anything stupid (for once!!)
you would proably be better off switching to themes to change the look.
I don't think Themes wouldn't help in this situation. Don't they only
apply to full pages? I need the rest of the page to stay as it is, and
just have this one bit display according to the style set by the site
owner.
Thanks anyway. I have been looking at themes, and they do look good, but
you have to know when they are applicable.
Ta ra
-- bruce (sqlwork.com) "Alan Silver" <al*********@nospam.thanx> wrote in message news:jr**************@nospamthankyou.spam... Hello,
I have a user control that has one .cs file, with several .ascx files that call it. The reason for this is that I can pick whichever of the .ascx files I want (based on a site owner setting), and I know the code-behind is the same in all cases. That way the .ascx file can be picked dynamically, allowing the appearance of the page to be changed based on a user setting.
This was working fine in 1.1, but had the code-behind compiled into a DLL. I'm trying to convert the user control(s) to use the new 2.0 code-behind model, and would like to avoid having to compile the DLL each time.
The page that uses the control has a placeholder called plcProductDetails, and has code like...
string fileName = "ShowProductStyle1.ascx"; // normally from user setting Control ctlShowProduct = LoadControl(fileName); ((ShowProduct)ctlShowProduct).DisplayProduct(); plcProductDetails.Controls.Add(ctlShowProduct);
Now this worked fine when using the old 1.1 code-behind model. I could compile ShowProduct.dll on its own and the code above would find it OK.
Now I have deleted the DLL, and changed the top of each of the .ascx files to look like...
<%@ Control CodeFile="ShowProduct.cs" Inherits="ShowProduct" %>
and the top of the code-behind file looks like...
// various "using" statements omitted for clarity public partial class ShowProduct : UserControl {
If I try to load the page now, I get an error...
"CS0246: The type or namespace name 'ShowProduct' could not be found"
on the line...
((ShowProduct)ctlShowProduct).DisplayProduct();
I don't know how to get around this. When LoadControl was called, it referenced the .ascx file, and that referenced the code-behind file that contains the class definition for ShowProduct. Why then can't the framework find the class?
I hope this is clear. I'm really lost here and would appreciate any clue as to how I am supposed to do this. The weird thing is that I tried creating a user control in VWD, and I could have two .ascx files referencing the same .cs file and they both work fine without me needing to compile anything. I'm obviously doing something wrong, but I can't see what.
TIA
-- Alan Silver (anything added below this line is nothing to do with me)
--
Alan Silver
(anything added below this line is nothing to do with me) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Oliver Elphick |
last post by:
The attached proposal is written primarily for Debian. Its
motivation is that the current package upgrade process is pretty flaky
and also that the current packaging does not really provide for...
|
by: Buck Rogers |
last post by:
Hi all! Newbie here.
Below is an example from Teach Yourself C in 21 Days. My apologies
if it is a bit long.
What I don't understand is how the "get_data" function can call the...
|
by: mike |
last post by:
I help manage a large web site, one that has over
600 html pages... It's a reference site for ham radio
folks and as an example, one page indexes over
1.8 gb of on-line PDF documents.
The site...
|
by: subramanian100in |
last post by:
Is my following understanding correct ?
Data abstraction means providing the interface - that is, the set of
functions that can be called by the user of a class.
Information hiding means...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |