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
plcProductDetai ls, and has code like...
string fileName = "ShowProductSty le1.ascx"; // normally from user
setting
Control ctlShowProduct = LoadControl(fil eName);
((ShowProduct)c tlShowProduct). DisplayProduct( );
plcProductDetai ls.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="ShowP roduct.cs" Inherits="ShowP roduct" %>
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)c tlShowProduct). 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 1258
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*********@no spam.thanx> wrote in message
news:jr******** ******@nospamth ankyou.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 plcProductDetai ls, and has code like...
string fileName = "ShowProductSty le1.ascx"; // normally from user setting Control ctlShowProduct = LoadControl(fil eName); ((ShowProduct)c tlShowProduct). DisplayProduct( ); plcProductDetai ls.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="ShowP roduct.cs" Inherits="ShowP roduct" %>
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)c tlShowProduct). 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*********@no spam.thanx> wrote in message news:jr******* *******@nospamt hankyou.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 plcProductDetai ls, and has code like...
string fileName = "ShowProductSty le1.ascx"; // normally from user setting Control ctlShowProduct = LoadControl(fil eName); ((ShowProduct)c tlShowProduct). DisplayProduct( ); plcProductDetai ls.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="ShowP roduct.cs" Inherits="ShowP roduct" %>
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)c tlShowProduct). 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 multiple
simultaneous postmasters, which are wanted by people hosting several
database clusters.
I assume these proposals may also be of interest to Red Hat packagers.
I am copying it to the PostgreSQL list in case there are any
obvious...
|
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
"continue_function", and if NO is returned to "get_data", display_report
executes and the program ends? Basically I am having trouble understanding
the program flow within the "if" loop in the "main" function.
|
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 is structured as an upside-down tree, and
(if I remember correctly) never more than 4 levels.
The site basically grew (like the creeping black blob) ...
all the pages were created in Notepad over the last
|
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 mentioning the class members(functions,
typedefs, data) under the access control labels : public, protected,
private.
Encapsulation means providing the implementation of class member
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |