473,396 Members | 1,815 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,396 software developers and data experts.

C# WEB: Using Custom Control from a different project

I have 2 projects, and accessing a custom control [which has an ImageButton], fron another project. Inside the custom control, it calls a function [which is also inside the same project as the custom control, passing the ImageButton] It compiles and when it runs I get a NullReference error message on the function which accepts the ImageButton. Basically custom control is called .. goes into execute functions, but the ImageButton control inside the custom control is not passed to the function. I'm thinking is it some permission blocking the visibility of the ImageButton?

the control works perfect when it is referenced inside the same project. Even in my project, I'm not accessing the ImageButton from my project. I'm just calling the custom control, which has a function passing the ImageButton.

ProjectA
--login.aspx
has
Expand|Select|Wrap|Line Numbers
  1. <ps:header id="uc_header1" runat="server"></ps:header>
ProjectB
--header.aspx
----ImageButton

in web.config

Expand|Select|Wrap|Line Numbers
  1. <system.web>
  2.         <pages>
  3.             <controls>
  4.                 <add tagPrefix="ps"
  5.                      namespace="PSubscribers"
  6.                      assembly="PSubscribers" />
  7.             </controls>
  8.         </pages>
  9.     </system.web>
Please somebody help me.
Aug 13 '08 #1
3 2404
Frinavale
9,735 Expert Mod 8TB
It calls a function [which is also inside the same project as the custom control, passing the ImageButton]
I'm not sure what you mean by this.
Could you please post the code where this function is called?
Aug 14 '08 #2
Here is the partial code of user control header.ascx.cs

Expand|Select|Wrap|Line Numbers
  1.     public partial class header : System.Web.UI.UserControl
  2.     {
  3.         protected void Page_Load(object sender, EventArgs e)
  4.         {
  5.             Page_Refresh();
  6.         }
  7.  
  8.         protected void Page_Refresh()
  9.         {
  10.             Myutils.Prepare_ImageButton_Rollover(varimgFontSize1, "fontsize1", Myutils.CSS_ID == 1);
  11.             Myutils.Prepare_ImageButton_Rollover(varimgFontSize2, "fontsize2", Myutils.CSS_ID == 2);
  12.            Myutils.Prepare_ImageButton_Rollover(varimgFontSize3, "fontsize3", Myutils.CSS_ID == 3);
  13.         }
where varimgFontSizeX is defined on the header.ascx page
Expand|Select|Wrap|Line Numbers
  1. <div class="changeFontSize"><asp:Image ID="varimgFontSize" runat="server" ImageUrl="~/images/en_fontsize.gif"  BorderWidth="0" 
  2.     /><asp:ImageButton ID="varimgFontSize1" runat="server" ImageUrl="~/images/en_fontsize1_off.gif"  BorderWidth="0" OnClick="varimgFontSize1_Click" 
  3.     /><asp:ImageButton ID="varimgFontSize2" runat="server" ImageUrl="~/images/en_fontsize2_off.gif"  BorderWidth="0" OnClick="varimgFontSize2_Click" 
  4.     /><asp:ImageButton ID="varimgFontSize3" runat="server" ImageUrl="~/images/en_fontsize3_off.gif"  BorderWidth="0" OnClick="varimgFontSize3_Click" 
  5.     /></div>
just to let you know, I don't have enough time. So I actually copied the user control to the project that I work on and linked like that [remember both Projects are under one Solution]. But it would be better to know this way, so you only have one usercontrol.

Oh I also found out that if I comment this function calling and put plain text -- just for testing. My page loads, except this user control is NOT displayed. Basically the header is not displayed. So I guess, even though the coding were able to see a control from the different project, it didn't recognize it as a Web User Control.

Thanks for you time. I'm not looking for answer, as I fixed my problem, not so good way. But it would be nice to know this too.
Aug 14 '08 #3
Frinavale
9,735 Expert Mod 8TB
Sorry, I'm at a loss as to why your ImageButtons are null....'

Unless you didn't include the .aspx.designer.cs in the new application?

-Frinny
Aug 14 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ben Taylor | last post by:
Hi I am trying to build, more for a learning project than anything, an ASP.NET web application in C# that will run on my local machine, which has now successully got IIS installed on it (XP pro)....
8
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
6
by: Klaus Jensen | last post by:
Hi! I have a pretty traditional setup where I develop on my local PC and the use "Copy Project" to deploy to the production enviroment.. In web.config I need different values for...
86
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
12
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded...
4
by: Richard Levasseur | last post by:
(Forewarning, most of these problems and solutions come from being the only developer in a 1 server department with no budget, few resources, unresponsive IT, and non-technical managers, so thats...
3
by: weboweb | last post by:
Hi, I'm new in web parts, I would like to understand a couple of things: Let's say I have a custom control that displays information. That info is fed to the control through an XML string, so...
5
by: John Kotuby | last post by:
Hi all, This is my first time trying to creaet and use a custome Web Control in a Web Site project in ASP.NET 2.0 with VS 2005 and VB. I created the control in a separate Web Control Library...
10
by: AG | last post by:
I am trying to use a ReportViewer control in a VS 2005 web application project (not Website project). When I try to create a new report (local), I can't seem to find any method to create a...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...

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.