Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Class Namespace not Accessible by User Control

Posted on 2006-06-16
5
Medium Priority
?
869 Views
Last Modified: 2013-11-19
Hi

VS 2005
VB.NET & C#

I popped a couple of classes into my site from here:
http://aspnet.4guysfromrolla.com/articles/020205-1.aspx

Each of the three classes start:
////////////////////////////////////////////////////////////////////////////
 using System;
using System.Collections;
using System.Web;

namespace ParameterPasser
{
....
....
////////////////////////////////////////////////////////////////////////////

To use I include an Imports statement in my forms:

////////////////////////////////////////////////////////////////////////////
Imports ParamaterPasser
....
....

        ' Pass textbox values to MyPage.aspx

        Dim sesssionWrapper As SessionParameterPasser = New SessionParameterPasser("MyPage.aspx")

        ' Add some values

        sesssionWrapper("Start_Date") = Start_Date

        ' Redirect to the page, passing the parameters in the querystring

        sesssionWrapper.PassParameters() This worked great but has recently failed. I get the following warning:
////////////////////////////////////////////////////////////////////////////

This works great in everyting but a user control (ascx  file) where I get this warning:

Namespace or type specified in the Imports 'ParamaterPasser' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

and the following error:

Type 'SessionParameterPasser' is not defined.

Is there some sort of gotcha re user controls and namespaces defined in a class of the same project?

Please let me know if you need me to supply more information.
0
Comment
Question by:pootle_flump
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:kGenius
ID: 16926644
Is there a constructor provided in the C# class?

Like
public class MyClass {

'constructor
public MyClass() { }

}
0
 
LVL 7

Accepted Solution

by:
kGenius earned 2000 total points
ID: 16926655
Another thougth.
When importing ParameterPasser, are you sure it is a top-level namespace? There's no other default namespace in the project properties provided? Then you should import xxx.ParameterPasser where xxx is the default namespace...

cf this MSDN article: http://support.microsoft.com/kb/304260/EN-US/

Hope this'll help
0
 
LVL 11

Author Comment

by:pootle_flump
ID: 16932626
Hi kGenius

Thanks for taking the time to help.

>>Is there a constructor provided in the C# class?
Yeppers:
Abstract class:
////////////////////////////////////////////
using System;
using System.Collections;
using System.Web;

namespace ParameterPasser
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    public abstract class BaseParameterPasser
    {
        #region Member Variables
        private string url = string.Empty;
        #endregion

        #region Constructors
        public BaseParameterPasser()
        {
            if (HttpContext.Current != null)
                url = HttpContext.Current.Request.Url.ToString();
        }

        public BaseParameterPasser(string Url)
        {
            this.url = Url;
        }
        #endregion
////////////////////////////////////////////
Instantiable class:
////////////////////////////////////////////
using System;
using System.Web;

namespace ParameterPasser
{
    /// <summary>
    /// Summary description for SessionParameterPasser.
    /// </summary>
    public class SessionParameterPasser : BaseParameterPasser
    {
        #region Constructors
        public SessionParameterPasser() : base() { }
        public SessionParameterPasser(string Url) : base(Url) { }
        #endregion
////////////////////////////////////////////

>>Another thougth.
I will follow it through and report back

Thanks
0
 
LVL 11

Author Comment

by:pootle_flump
ID: 16932655
Hmmmmm.

Ok - it looks like it was intermittant\ a bug. I was just refreshing my memory of the problem (having submitted it on Friday).

The Imports ParameterPasser line was underlined and causing the error. It was spelt correctly (I had copied and pasted from a working form). I typed in Imports again and what do you know - ParametPasser appeared in Intellisense (it wasn't there on Friday).

I've had similar problems with VS2005 before but normally closing down VS and reopening sorts it out. It hadn't done so this time so I posted the question. I guess it really wanted a restart lol.

Many thanks for your help kGenius
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16932668
many thanx for the points ...
Glad you figured it out!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question