Re: Not able to put class into namespace



asp.net uses partial the partial class model to combine the codebenind file and the class file generated by the page compile.

if the namspace of the page (which defines the control names) is different then the namespace in codebehind, then you need to fully qualify the control names as they are in a differnt namespace.

I believe the default namespace for the page is ASP. You could also make the namespace of the page match the codebehind namespace via the ClassName in the <@page> directive.

note: designer files are only required with web applications, and not sure if they support namespaces.

-- bruce (sqlwork.com)



K Viltersten wrote:
I've designed a class as below.

public partial class Test : System.Web.UI.Page {
protected void Page_Load(
object sender, EventArgs e)
{
...
ThatLabel.Text = "!";
...
} ...
}

Now, i'd like to place it into a namespace but when i do that, it seems
that the controls i refer to (ThatLabel)
are, do not exist in the current context.

What is the reason for that and how can
i resolve the problem?

The only guess i have is that the class
begin partial, has other parts of it somewhere and THAT OTHER part, declaring
and creating the actual control, gets placed OUTSIDE the new namespace. However, i haven't found "the rest" of
the code. How can i get to it?

.



Relevant Pages

  • Accessing namespaces referenced in codebehind of an ascx file
    ... I have included a namespace in the "using" statements at the top of the ... codebehind page for an ascx page (user control). ... How can I access the objects in this namespace from the ascx page ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Why null reference to ListBox?
    ... I'm not sure what NameSpace means here. ... Search for Listbox ... Given that I dragged a graphical representation of a control from a ... sub aaaa ...
    (microsoft.public.excel.programming)
  • Problem using remote controls
    ... instance of a class and marshals it. ... GetControl() which returns the control to display the informations of the ... namespace Interfaces ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Cannot get a handle on web UserControls in ASP 2.0
    ... ASP 2.0 by resolving this namespace issue and getting a handle on control ... control loose in the root, I can access it statically from the default page. ... What bothers me is there does not appear to be a central location ... >> worst problem I've run into is all references to ...
    (microsoft.public.dotnet.framework.aspnet)
  • usercontrol question (C++)
    ... Then display the time in one of the panels using a timer control to ... using namespace System::ComponentModel; ... /// 'Resource File Name' property for the managed resource compiler tool ... void InitializeComponent ...
    (microsoft.public.dotnet.framework.windowsforms.controls)

Loading