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

Wrapping all elements of .NET project in Namespace

74
For some reason the aspx web pages and web user controls in my project cannot see one another.

I have gone through most of them and added them to a namespace so that I can refer to my objects in my code...

Expand|Select|Wrap|Line Numbers
  1. Namespace MyNamespace
  2.     Partial Class MyPage
  3. ....
  4.     End Class
  5. End Namesapce
  6.  
Expand|Select|Wrap|Line Numbers
  1. <%@ Control Language="VB" AutoEventWireup="false" CodeFile="MyPage.ascx.vb" Inherits="MyNamespace.MyPage" %>
  2.  
Here's my problem:
For some reason the namespace contains different classes when I refer to it in different classes in my project.

Eg.
Referring to MyNamespace in MyPage will show 3 components...whereas referring to MyNamespace in MyOtherPage will show those 3 components and a couple of others.

Does anyone know why this is happening?
Am I not adding the namespace properly?
Why can't my project's components just be aware of the other components in the project?

Any advice on the situation would be greatly appreciated!
Thanks

-LilOlMe
Oct 15 '07 #1
5 916
lilOlMe
74
I don't know why the namespace is different in different classes...but I got around the problem.

What I did was create a MustInherit Class to represent the Web User Control that I needed to refer to. I placed this class in the namespace for the project.

This class is placed in the "App_Code" folder in the project (I noticed that the classes in this folder were always added to the namespace).

This class Inherits the System.Web.UI.UserControl class.

I then declared the Subs and Functions that I wanted to expose to the rest of the code as Public MustOverride.

Then back in the Web User Control I changed it to Inherit the class that I just created (instead of inheriting System.Web.UI.UserControl).


EG:
The following is the class that exposes my Web User Control's code to my other code in the project:
Expand|Select|Wrap|Line Numbers
  1. Imports Microsoft.VisualBasic
  2. Namespace MyNamespace
  3.     Public MustInherit Class MyUserControl
  4.         Inherits System.Web.UI.UserControl
  5.  
  6.         Public MustOverride Sub TheSubThatNeedsToBeExposed()
  7.  
  8.     End Class
  9. End Namespace
  10.  
The Web User Control was changed to be:
Expand|Select|Wrap|Line Numbers
  1. Namespace MyNamespace
  2.     Partial Class Impl_MyUserControl 'This used to be MyUserControl
  3.         Inherits MyUserControl 'This used to be: Inherits System.Web.UI.UserControl
  4.          Public Overrides Sub TheSubThatNeedsToBeExposed() 'This sub is now exposed to other code
  5.              '....
  6.          End Sub
  7.      End Class
  8. End Namespace
  9.  
And the Asp for my Web User Control was changed to properly inherit the server side code like so:
Expand|Select|Wrap|Line Numbers
  1. <%@ Control Language="VB" AutoEventWireup="false" CodeFile="MyUserControl.ascx.vb" Inherits="MyNamespace.Impl_MyUserControl" %>
Oct 15 '07 #2
Plater
7,872 Expert 4TB
None of my webobjects appear to HAVE a namespace at all?
Oct 15 '07 #3
lilOlMe
74
None of my webobjects appear to HAVE a namespace at all?
From what I understand there is a Default namespace created and everything should work fine.

However, there is something preventing my web objects from referring to one another.

That is why I created a namespace and put all of my web objects into it.

I'm still not sure why I couldn't refer to the other classes in my code.
I'm also unsure of why, when I added the namespace, certain classes could only access a limited number of other classes in that namespace.

I was hoping someone here might know the answer.
Although, I'm content with the solution that I've come up with...I'm still curious as to why it didn't work the way I thought it should in the first place.
Oct 15 '07 #4
Plater
7,872 Expert 4TB
Possibly one of those "Protected" instead of "Public" keywords or something?
It is very strange.
Oct 15 '07 #5
lilOlMe
74
Possibly one of those "Protected" instead of "Public" keywords or something?
It is very strange.
It was for a Public Class though.....

Oh well...if anyone else runs into this problem, hopefully my solution can work for them too.
Oct 15 '07 #6

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

Similar topics

0
by: C. M. Sperberg-McQueen | last post by:
wooks (wookiz@hotmail.com) wrote: > <?xml version='1.0'?> > <userlogin xmlns="urn:faster:userlogin" > xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> > <login>mick</login> > ...
8
by: Hugh Sparks | last post by:
When processing an xml document that contains elements such as: <element xmlns="goop"/> ... <element xmlns="gleep"/> I want to create two xsl stylesheet templates: one that matches the...
0
by: Stefan Behnel | last post by:
Hi! In a project, I'm providing an API that is made up by augmenting XML DOM elements with tag specific attributes and methods. These actually operate on the DOM and fulfill the need of making...
1
by: jsroberts | last post by:
I have been desperately trying to solve a problem where I am wrapping an unmanaged dll with managed extensions for c++ and then calling the managed dll functions from C#. However, whenever I call...
5
by: Lee Crabtree | last post by:
More fun wrapping unmanaged code... I have a class heirarchy that I need to expose to C#, so I need to wrap all the classes. That's not a big deal, except for the base class, which is abstract....
10
by: Tom the Canuck | last post by:
What would be the best way to proceed? Should I make a pure virtual class and then derive from that? I want the base class to have functions defined so that I don't have to do the work all over...
0
by: =?Utf-8?B?Y2hyaXNiZW4=?= | last post by:
Hi, I am getting quite frustrated while trying to wrap a C++ static library using managed C++ to a dll. Here are what I tried first, try to wrap it is a normal dll with some functions. seems...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
6
by: =?Utf-8?B?TUNN?= | last post by:
The following sections appears in my web.config file. <configuration> <system.web> <compilation> <assemblies> <add assembly="System.Core, Version=3.5.0.0, Culture=neutral,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
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,...
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...

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.