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

'Context' is not a member of....

I have a user control named Enter.ascx which has 2 TextBoxes. The 2
TextBoxes are named txt1 & txt2. The entire logic of this user control
(like the properties of the 2 TextBoxes using set/get etc.) is
encapsulated in a code behind page named Enter.ascx.vb. The code-behind
also creates TextChanged events for the 2 TextBoxes. This is the code
in Enter.ascx.vb:

Namespace Details
Public Class EnterCB : Inherits UserControl
Public WithEvents txt1 As TextBox
Public WithEvents txt2 As TextBox

'creating a few Properties for the
'2 TextBoxes using Set/Get

'create events for the 2 TextBoxes
Public Event TextChangedEvent(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub

Protected Sub txt2Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub
End Class
End Namespace

This is how I am encompassing the above code behind in Enter.ascx:

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

<asp:TextBox ID="txt1" runat="server"><br>
<asp:TextBox ID="txt2" runat="server">

As such the above user control when registered in an ASPX page works
fine & even the Events associated with the 2 TextBoxes in the user
control fire in the ASPX page when the text in the TextBoxes change.

But Visual Web Developer 2005 Express Edition (which is what I use for
creating & editing ASP.NET apps) throws the following error

'Context' is not a member of 'ASP.enter_ascx'.

when the mouse is moved over the

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

line in Enter.ascx. Now first of all, what does this error mean? What
is 'Context' here? & secondly, why is VWD generating this error?

Nov 24 '06 #1
8 29742
I could be wrong, but shouldn't your @Control directive have a CodeFile
attribute which points to the .vb file?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11*********************@l39g2000cwd.googlegro ups.com...
>I have a user control named Enter.ascx which has 2 TextBoxes. The 2
TextBoxes are named txt1 & txt2. The entire logic of this user control
(like the properties of the 2 TextBoxes using set/get etc.) is
encapsulated in a code behind page named Enter.ascx.vb. The code-behind
also creates TextChanged events for the 2 TextBoxes. This is the code
in Enter.ascx.vb:

Namespace Details
Public Class EnterCB : Inherits UserControl
Public WithEvents txt1 As TextBox
Public WithEvents txt2 As TextBox

'creating a few Properties for the
'2 TextBoxes using Set/Get

'create events for the 2 TextBoxes
Public Event TextChangedEvent(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub

Protected Sub txt2Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub
End Class
End Namespace

This is how I am encompassing the above code behind in Enter.ascx:

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

<asp:TextBox ID="txt1" runat="server"><br>
<asp:TextBox ID="txt2" runat="server">

As such the above user control when registered in an ASPX page works
fine & even the Events associated with the 2 TextBoxes in the user
control fire in the ASPX page when the text in the TextBoxes change.

But Visual Web Developer 2005 Express Edition (which is what I use for
creating & editing ASP.NET apps) throws the following error

'Context' is not a member of 'ASP.enter_ascx'.

when the mouse is moved over the

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

line in Enter.ascx. Now first of all, what does this error mean? What
is 'Context' here? & secondly, why is VWD generating this error?
Nov 24 '06 #2
Karl, I don't think that the absence of CodeFile is the cause of the
problem. You have replied to my post titled "App_Code & bin". VWD
behaves erratically in this case precisely because of the same reason
i.e. if I relocate the code behind Enter.ascx.vb to some directory
other than the App_Code directory & then compile Enter.ascx.vb into a
DLL in the bin directory using VBC, then VWD no longer displays the

'Context' is not a member of 'ASP.enter_ascx'

error when the mouse is moved over the line

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

in VWD but if I just have the code behind Enter.ascx.vb in the App_Code
directory (& no DLL in the bin directory), then VWD shows the above
error when the mouse is hovered over the above line.

BTW, could you please explain me what does "Context" mean here?
Karl Seguin wrote:
I could be wrong, but shouldn't your @Control directive have a CodeFile
attribute which points to the .vb file?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11*********************@l39g2000cwd.googlegro ups.com...
I have a user control named Enter.ascx which has 2 TextBoxes. The 2
TextBoxes are named txt1 & txt2. The entire logic of this user control
(like the properties of the 2 TextBoxes using set/get etc.) is
encapsulated in a code behind page named Enter.ascx.vb. The code-behind
also creates TextChanged events for the 2 TextBoxes. This is the code
in Enter.ascx.vb:

Namespace Details
Public Class EnterCB : Inherits UserControl
Public WithEvents txt1 As TextBox
Public WithEvents txt2 As TextBox

'creating a few Properties for the
'2 TextBoxes using Set/Get

'create events for the 2 TextBoxes
Public Event TextChangedEvent(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub

Protected Sub txt2Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub
End Class
End Namespace

This is how I am encompassing the above code behind in Enter.ascx:

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

<asp:TextBox ID="txt1" runat="server"><br>
<asp:TextBox ID="txt2" runat="server">

As such the above user control when registered in an ASPX page works
fine & even the Events associated with the 2 TextBoxes in the user
control fire in the ASPX page when the text in the TextBoxes change.

But Visual Web Developer 2005 Express Edition (which is what I use for
creating & editing ASP.NET apps) throws the following error

'Context' is not a member of 'ASP.enter_ascx'.

when the mouse is moved over the

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

line in Enter.ascx. Now first of all, what does this error mean? What
is 'Context' here? & secondly, why is VWD generating this error?
Nov 24 '06 #3
re:
could you please explain me what does "Context" mean here?
"Context" is a member of "System.Web.UI.Page".

Outside of the scope of a page class, you can only see it
by means of the static reference via "System.Web.HttpContext.Current".

If you don't have a page context, i.e., if you are making a call from code-behind
or from a DLL, then you need to invoke System.Web.HttpContext.Current.

HttpContext ctx = HttpContext.Current;


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<rn**@rediffmail.comwrote in message news:11**********************@j44g2000cwa.googlegr oups.com...
Karl, I don't think that the absence of CodeFile is the cause of the
problem. You have replied to my post titled "App_Code & bin". VWD
behaves erratically in this case precisely because of the same reason
i.e. if I relocate the code behind Enter.ascx.vb to some directory
other than the App_Code directory & then compile Enter.ascx.vb into a
DLL in the bin directory using VBC, then VWD no longer displays the

'Context' is not a member of 'ASP.enter_ascx'

error when the mouse is moved over the line

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

in VWD but if I just have the code behind Enter.ascx.vb in the App_Code
directory (& no DLL in the bin directory), then VWD shows the above
error when the mouse is hovered over the above line.

BTW, could you please explain me what does "Context" mean here?
Karl Seguin wrote:
>I could be wrong, but shouldn't your @Control directive have a CodeFile
attribute which points to the .vb file?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11*********************@l39g2000cwd.googlegr oups.com...
>I have a user control named Enter.ascx which has 2 TextBoxes. The 2
TextBoxes are named txt1 & txt2. The entire logic of this user control
(like the properties of the 2 TextBoxes using set/get etc.) is
encapsulated in a code behind page named Enter.ascx.vb. The code-behind
also creates TextChanged events for the 2 TextBoxes. This is the code
in Enter.ascx.vb:

Namespace Details
Public Class EnterCB : Inherits UserControl
Public WithEvents txt1 As TextBox
Public WithEvents txt2 As TextBox

'creating a few Properties for the
'2 TextBoxes using Set/Get

'create events for the 2 TextBoxes
Public Event TextChangedEvent(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub

Protected Sub txt2Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub
End Class
End Namespace

This is how I am encompassing the above code behind in Enter.ascx:

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

<asp:TextBox ID="txt1" runat="server"><br>
<asp:TextBox ID="txt2" runat="server">

As such the above user control when registered in an ASPX page works
fine & even the Events associated with the 2 TextBoxes in the user
control fire in the ASPX page when the text in the TextBoxes change.

But Visual Web Developer 2005 Express Edition (which is what I use for
creating & editing ASP.NET apps) throws the following error

'Context' is not a member of 'ASP.enter_ascx'.

when the mouse is moved over the

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

line in Enter.ascx. Now first of all, what does this error mean? What
is 'Context' here? & secondly, why is VWD generating this error?

Nov 24 '06 #4
Actually, I'm about 90% sure that I'm right...did you give it a try? it's a
pretty simple fix to try and solve your problem...

The problem is that the ascx file expects to have access to the Context
variable which is accessible as part of the UserControl class...

because you don't have a CodeFile, your ASCX file doesn't have any
codebehind associated with it...so there's no context...

It works when you drop a dll into the bin folder because the Inherits kicks
in and now there IS a codebehind file for your class which does inherit from
UserControl so there IS a Context variable...

You're mixing CodeFile and Inherits...

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
Karl, I don't think that the absence of CodeFile is the cause of the
problem. You have replied to my post titled "App_Code & bin". VWD
behaves erratically in this case precisely because of the same reason
i.e. if I relocate the code behind Enter.ascx.vb to some directory
other than the App_Code directory & then compile Enter.ascx.vb into a
DLL in the bin directory using VBC, then VWD no longer displays the

'Context' is not a member of 'ASP.enter_ascx'

error when the mouse is moved over the line

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

in VWD but if I just have the code behind Enter.ascx.vb in the App_Code
directory (& no DLL in the bin directory), then VWD shows the above
error when the mouse is hovered over the above line.

BTW, could you please explain me what does "Context" mean here?
Karl Seguin wrote:
>I could be wrong, but shouldn't your @Control directive have a CodeFile
attribute which points to the .vb file?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11*********************@l39g2000cwd.googlegr oups.com...
>I have a user control named Enter.ascx which has 2 TextBoxes. The 2
TextBoxes are named txt1 & txt2. The entire logic of this user control
(like the properties of the 2 TextBoxes using set/get etc.) is
encapsulated in a code behind page named Enter.ascx.vb. The code-behind
also creates TextChanged events for the 2 TextBoxes. This is the code
in Enter.ascx.vb:

Namespace Details
Public Class EnterCB : Inherits UserControl
Public WithEvents txt1 As TextBox
Public WithEvents txt2 As TextBox

'creating a few Properties for the
'2 TextBoxes using Set/Get

'create events for the 2 TextBoxes
Public Event TextChangedEvent(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub

Protected Sub txt2Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub
End Class
End Namespace

This is how I am encompassing the above code behind in Enter.ascx:

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

<asp:TextBox ID="txt1" runat="server"><br>
<asp:TextBox ID="txt2" runat="server">

As such the above user control when registered in an ASPX page works
fine & even the Events associated with the 2 TextBoxes in the user
control fire in the ASPX page when the text in the TextBoxes change.

But Visual Web Developer 2005 Express Edition (which is what I use for
creating & editing ASP.NET apps) throws the following error

'Context' is not a member of 'ASP.enter_ascx'.

when the mouse is moved over the

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

line in Enter.ascx. Now first of all, what does this error mean? What
is 'Context' here? & secondly, why is VWD generating this error?
Nov 24 '06 #5
Karl, assuming that the code behind of the user control i.e
Enter.ascx.vb resides in the App_Code directory, if I add the CodeFile
attribute to the @Control directive like this:

<%@ Control Language="VB" CodeFile="App_Code\Enter.ascx.vb"
Inherits="Details.EnterCB" %>

the following error gets generated:

The file '/aspx/App_Code/Enter.ascx.vb' is in the special directory
'App_Code', which is not allowed.

If the code behind of the user control Enter.ascx.vb is placed in some
directory other than the App_Code, then when I try to use this user
control in the code behind of an ASPX page by importing the namespace &
using the class name as the type

Imports Details
Public Class MyClass : Inherits Page
Public Enter1 As EnterCB
........
........
End Class

then I get the following error:

Type 'EnterCB' is not defined.

pointing to the line which declares the variable 'Enter1'.

I also compiled Enter.ascx.vb into a DLL in the bin directory
(Enter.ascx.vb not residing in the App_Code directory) & used the
CodeFile attribute in the @Control directive in the ascx file but this
generates the following error:

Make sure that the class defined in this code file matches the
'inherits' attribute, and that it extends the correct base class (e.g.
Page or UserControl).

which points to the

Imports System

line in Enter.ascx.vb. I have ensured both the conditions outlined in
the error message but I don't understand why the error persists.

It's better I adhere to the DLL in the bin directory without using the
CodeFile attribute in the @Control directive. The more I delve into
this, the more I am getting confused....
Karl Seguin wrote:
Actually, I'm about 90% sure that I'm right...did you give it a try? it's a
pretty simple fix to try and solve your problem...

The problem is that the ascx file expects to have access to the Context
variable which is accessible as part of the UserControl class...

because you don't have a CodeFile, your ASCX file doesn't have any
codebehind associated with it...so there's no context...

It works when you drop a dll into the bin folder because the Inherits kicks
in and now there IS a codebehind file for your class which does inherit from
UserControl so there IS a Context variable...

You're mixing CodeFile and Inherits...

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
Karl, I don't think that the absence of CodeFile is the cause of the
problem. You have replied to my post titled "App_Code & bin". VWD
behaves erratically in this case precisely because of the same reason
i.e. if I relocate the code behind Enter.ascx.vb to some directory
other than the App_Code directory & then compile Enter.ascx.vb into a
DLL in the bin directory using VBC, then VWD no longer displays the

'Context' is not a member of 'ASP.enter_ascx'

error when the mouse is moved over the line

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

in VWD but if I just have the code behind Enter.ascx.vb in the App_Code
directory (& no DLL in the bin directory), then VWD shows the above
error when the mouse is hovered over the above line.

BTW, could you please explain me what does "Context" mean here?
Karl Seguin wrote:
I could be wrong, but shouldn't your @Control directive have a CodeFile
attribute which points to the .vb file?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11*********************@l39g2000cwd.googlegro ups.com...
I have a user control named Enter.ascx which has 2 TextBoxes. The 2
TextBoxes are named txt1 & txt2. The entire logic of this user control
(like the properties of the 2 TextBoxes using set/get etc.) is
encapsulated in a code behind page named Enter.ascx.vb. The code-behind
also creates TextChanged events for the 2 TextBoxes. This is the code
in Enter.ascx.vb:

Namespace Details
Public Class EnterCB : Inherits UserControl
Public WithEvents txt1 As TextBox
Public WithEvents txt2 As TextBox

'creating a few Properties for the
'2 TextBoxes using Set/Get

'create events for the 2 TextBoxes
Public Event TextChangedEvent(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub

Protected Sub txt2Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub
End Class
End Namespace

This is how I am encompassing the above code behind in Enter.ascx:

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

<asp:TextBox ID="txt1" runat="server"><br>
<asp:TextBox ID="txt2" runat="server">

As such the above user control when registered in an ASPX page works
fine & even the Events associated with the 2 TextBoxes in the user
control fire in the ASPX page when the text in the TextBoxes change.

But Visual Web Developer 2005 Express Edition (which is what I use for
creating & editing ASP.NET apps) throws the following error

'Context' is not a member of 'ASP.enter_ascx'.

when the mouse is moved over the

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

line in Enter.ascx. Now first of all, what does this error mean? What
is 'Context' here? & secondly, why is VWD generating this error?
Nov 24 '06 #6
the .vb codefile should be in the same directory as the .ascx

to use it within your page, you need to add a @References directive to your
page, as opposed to an imports.

%@References Control="~/Enter.ascx" %

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11**********************@j72g2000cwa.googlegr oups.com...
Karl, assuming that the code behind of the user control i.e
Enter.ascx.vb resides in the App_Code directory, if I add the CodeFile
attribute to the @Control directive like this:

<%@ Control Language="VB" CodeFile="App_Code\Enter.ascx.vb"
Inherits="Details.EnterCB" %>

the following error gets generated:

The file '/aspx/App_Code/Enter.ascx.vb' is in the special directory
'App_Code', which is not allowed.

If the code behind of the user control Enter.ascx.vb is placed in some
directory other than the App_Code, then when I try to use this user
control in the code behind of an ASPX page by importing the namespace &
using the class name as the type

Imports Details
Public Class MyClass : Inherits Page
Public Enter1 As EnterCB
........
........
End Class

then I get the following error:

Type 'EnterCB' is not defined.

pointing to the line which declares the variable 'Enter1'.

I also compiled Enter.ascx.vb into a DLL in the bin directory
(Enter.ascx.vb not residing in the App_Code directory) & used the
CodeFile attribute in the @Control directive in the ascx file but this
generates the following error:

Make sure that the class defined in this code file matches the
'inherits' attribute, and that it extends the correct base class (e.g.
Page or UserControl).

which points to the

Imports System

line in Enter.ascx.vb. I have ensured both the conditions outlined in
the error message but I don't understand why the error persists.

It's better I adhere to the DLL in the bin directory without using the
CodeFile attribute in the @Control directive. The more I delve into
this, the more I am getting confused....
Karl Seguin wrote:
>Actually, I'm about 90% sure that I'm right...did you give it a try? it's
a
pretty simple fix to try and solve your problem...

The problem is that the ascx file expects to have access to the Context
variable which is accessible as part of the UserControl class...

because you don't have a CodeFile, your ASCX file doesn't have any
codebehind associated with it...so there's no context...

It works when you drop a dll into the bin folder because the Inherits
kicks
in and now there IS a codebehind file for your class which does inherit
from
UserControl so there IS a Context variable...

You're mixing CodeFile and Inherits...

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googleg roups.com...
Karl, I don't think that the absence of CodeFile is the cause of the
problem. You have replied to my post titled "App_Code & bin". VWD
behaves erratically in this case precisely because of the same reason
i.e. if I relocate the code behind Enter.ascx.vb to some directory
other than the App_Code directory & then compile Enter.ascx.vb into a
DLL in the bin directory using VBC, then VWD no longer displays the

'Context' is not a member of 'ASP.enter_ascx'

error when the mouse is moved over the line

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

in VWD but if I just have the code behind Enter.ascx.vb in the App_Code
directory (& no DLL in the bin directory), then VWD shows the above
error when the mouse is hovered over the above line.

BTW, could you please explain me what does "Context" mean here?
Karl Seguin wrote:
I could be wrong, but shouldn't your @Control directive have a
CodeFile
attribute which points to the .vb file?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11*********************@l39g2000cwd.googlegr oups.com...
I have a user control named Enter.ascx which has 2 TextBoxes. The 2
TextBoxes are named txt1 & txt2. The entire logic of this user
control
(like the properties of the 2 TextBoxes using set/get etc.) is
encapsulated in a code behind page named Enter.ascx.vb. The
code-behind
also creates TextChanged events for the 2 TextBoxes. This is the
code
in Enter.ascx.vb:

Namespace Details
Public Class EnterCB : Inherits UserControl
Public WithEvents txt1 As TextBox
Public WithEvents txt2 As TextBox

'creating a few Properties for the
'2 TextBoxes using Set/Get

'create events for the 2 TextBoxes
Public Event TextChangedEvent(ByVal obj As Object, ByVal ea
As
EventArgs)

Protected Sub txt1Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub

Protected Sub txt2Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub
End Class
End Namespace

This is how I am encompassing the above code behind in Enter.ascx:

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

<asp:TextBox ID="txt1" runat="server"><br>
<asp:TextBox ID="txt2" runat="server">

As such the above user control when registered in an ASPX page works
fine & even the Events associated with the 2 TextBoxes in the user
control fire in the ASPX page when the text in the TextBoxes change.

But Visual Web Developer 2005 Express Edition (which is what I use
for
creating & editing ASP.NET apps) throws the following error

'Context' is not a member of 'ASP.enter_ascx'.

when the mouse is moved over the

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

line in Enter.ascx. Now first of all, what does this error mean?
What
is 'Context' here? & secondly, why is VWD generating this error?

Nov 24 '06 #7
Karl, does the CodeFile attribute in the Page directive mean the code
behind file? Assuming that the code behind exists in the same directory
as the ASPX page, when should one use Imports & when should one use
References?

The 1-line code snippet that you have shown, in which file should it be
added? In the code behind of the ASPX page that uses the user control?

OK...just tell me one thing - I have a user control named Enter.ascx
which has a code behind named Enter.ascx.vb. An ASPX page named
MyPage.aspx makes use of this user control but MyPage.aspx only has the
UI elements - the entire logic of MyPage.aspx is in another code behind
named MyPage.aspx.vb. All the 4 files exist in the same directory.

Now

1. how do I tell Enter.ascx to use its code behind Enter.ascx.vb?

I want to use this user control in the ASPX page.

2. how do I tell the ASPX page to use the user control? Should the user
control be IMPORTed in the code behind of the ASPX page i.e. in
MyPage.aspx.vb or should the user control be REFERENCEd in
MyPage.aspx.vb?

3. how do I use the code behind of the ASPX page i.e. MyPage.aspx.vb in
MyPage.aspx?
Karl Seguin wrote:
the .vb codefile should be in the same directory as the .ascx

to use it within your page, you need to add a @References directive to your
page, as opposed to an imports.

%@References Control="~/Enter.ascx" %

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11**********************@j72g2000cwa.googlegr oups.com...
Karl, assuming that the code behind of the user control i.e
Enter.ascx.vb resides in the App_Code directory, if I add the CodeFile
attribute to the @Control directive like this:

<%@ Control Language="VB" CodeFile="App_Code\Enter.ascx.vb"
Inherits="Details.EnterCB" %>

the following error gets generated:

The file '/aspx/App_Code/Enter.ascx.vb' is in the special directory
'App_Code', which is not allowed.

If the code behind of the user control Enter.ascx.vb is placed in some
directory other than the App_Code, then when I try to use this user
control in the code behind of an ASPX page by importing the namespace &
using the class name as the type

Imports Details
Public Class MyClass : Inherits Page
Public Enter1 As EnterCB
........
........
End Class

then I get the following error:

Type 'EnterCB' is not defined.

pointing to the line which declares the variable 'Enter1'.

I also compiled Enter.ascx.vb into a DLL in the bin directory
(Enter.ascx.vb not residing in the App_Code directory) & used the
CodeFile attribute in the @Control directive in the ascx file but this
generates the following error:

Make sure that the class defined in this code file matches the
'inherits' attribute, and that it extends the correct base class (e.g.
Page or UserControl).

which points to the

Imports System

line in Enter.ascx.vb. I have ensured both the conditions outlined in
the error message but I don't understand why the error persists.

It's better I adhere to the DLL in the bin directory without using the
CodeFile attribute in the @Control directive. The more I delve into
this, the more I am getting confused....
Karl Seguin wrote:
Actually, I'm about 90% sure that I'm right...did you give it a try? it's
a
pretty simple fix to try and solve your problem...

The problem is that the ascx file expects to have access to the Context
variable which is accessible as part of the UserControl class...

because you don't have a CodeFile, your ASCX file doesn't have any
codebehind associated with it...so there's no context...

It works when you drop a dll into the bin folder because the Inherits
kicks
in and now there IS a codebehind file for your class which does inherit
from
UserControl so there IS a Context variable...

You're mixing CodeFile and Inherits...

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
Karl, I don't think that the absence of CodeFile is the cause of the
problem. You have replied to my post titled "App_Code & bin". VWD
behaves erratically in this case precisely because of the same reason
i.e. if I relocate the code behind Enter.ascx.vb to some directory
other than the App_Code directory & then compile Enter.ascx.vb into a
DLL in the bin directory using VBC, then VWD no longer displays the

'Context' is not a member of 'ASP.enter_ascx'

error when the mouse is moved over the line

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

in VWD but if I just have the code behind Enter.ascx.vb in the App_Code
directory (& no DLL in the bin directory), then VWD shows the above
error when the mouse is hovered over the above line.

BTW, could you please explain me what does "Context" mean here?
Karl Seguin wrote:
I could be wrong, but shouldn't your @Control directive have a
CodeFile
attribute which points to the .vb file?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11*********************@l39g2000cwd.googlegro ups.com...
I have a user control named Enter.ascx which has 2 TextBoxes. The 2
TextBoxes are named txt1 & txt2. The entire logic of this user
control
(like the properties of the 2 TextBoxes using set/get etc.) is
encapsulated in a code behind page named Enter.ascx.vb. The
code-behind
also creates TextChanged events for the 2 TextBoxes. This is the
code
in Enter.ascx.vb:

Namespace Details
Public Class EnterCB : Inherits UserControl
Public WithEvents txt1 As TextBox
Public WithEvents txt2 As TextBox

'creating a few Properties for the
'2 TextBoxes using Set/Get

'create events for the 2 TextBoxes
Public Event TextChangedEvent(ByVal obj As Object, ByVal ea
As
EventArgs)

Protected Sub txt1Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub

Protected Sub txt2Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub
End Class
End Namespace

This is how I am encompassing the above code behind in Enter.ascx:

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

<asp:TextBox ID="txt1" runat="server"><br>
<asp:TextBox ID="txt2" runat="server">

As such the above user control when registered in an ASPX page works
fine & even the Events associated with the 2 TextBoxes in the user
control fire in the ASPX page when the text in the TextBoxes change.

But Visual Web Developer 2005 Express Edition (which is what I use
for
creating & editing ASP.NET apps) throws the following error

'Context' is not a member of 'ASP.enter_ascx'.

when the mouse is moved over the

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

line in Enter.ascx. Now first of all, what does this error mean?
What
is 'Context' here? & secondly, why is VWD generating this error?
Nov 24 '06 #8
the model in 2.0 works differently then what you are used to.

In 2.0, by default, everything is JIT-ed, including the "codebehind" which
is now refered to as the CodeFile.

The reason you need to use References vs Imports is: in 2.0 each aspx and
codefile is compiled into it's OWN assembly - who's name is dynamically
created, something like aslv93l.dll (for example). So you must reference
those assemblies in order to use their classes...However, since you don't
know the dynamic name, the ASP.NET team lets you add a reference to a
usercontrol or a page via the @References directive.

You use @Reference in the page to say "this page uses these user
controls..." and make the user control's type available to the page...You
can use Reference on a user control and point it to the page to do the
opposite, but this has the side effect of locking your user control to that
page - which isn't very good.

1 - You should just have to specify the CodeFile=Enter.ascx.vb in the
@Control directive...
2 - No, it needs to be referenced...this all has to do with each
file/codefile being compiled into it's own assembly..
3 - Pages work the same as user controls...you should be using CodeFiles...

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11**********************@14g2000cws.googlegro ups.com...
Karl, does the CodeFile attribute in the Page directive mean the code
behind file? Assuming that the code behind exists in the same directory
as the ASPX page, when should one use Imports & when should one use
References?

The 1-line code snippet that you have shown, in which file should it be
added? In the code behind of the ASPX page that uses the user control?

OK...just tell me one thing - I have a user control named Enter.ascx
which has a code behind named Enter.ascx.vb. An ASPX page named
MyPage.aspx makes use of this user control but MyPage.aspx only has the
UI elements - the entire logic of MyPage.aspx is in another code behind
named MyPage.aspx.vb. All the 4 files exist in the same directory.

Now

1. how do I tell Enter.ascx to use its code behind Enter.ascx.vb?

I want to use this user control in the ASPX page.

2. how do I tell the ASPX page to use the user control? Should the user
control be IMPORTed in the code behind of the ASPX page i.e. in
MyPage.aspx.vb or should the user control be REFERENCEd in
MyPage.aspx.vb?

3. how do I use the code behind of the ASPX page i.e. MyPage.aspx.vb in
MyPage.aspx?
Karl Seguin wrote:
>the .vb codefile should be in the same directory as the .ascx

to use it within your page, you need to add a @References directive to
your
page, as opposed to an imports.

%@References Control="~/Enter.ascx" %

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11**********************@j72g2000cwa.googleg roups.com...
Karl, assuming that the code behind of the user control i.e
Enter.ascx.vb resides in the App_Code directory, if I add the CodeFile
attribute to the @Control directive like this:

<%@ Control Language="VB" CodeFile="App_Code\Enter.ascx.vb"
Inherits="Details.EnterCB" %>

the following error gets generated:

The file '/aspx/App_Code/Enter.ascx.vb' is in the special directory
'App_Code', which is not allowed.

If the code behind of the user control Enter.ascx.vb is placed in some
directory other than the App_Code, then when I try to use this user
control in the code behind of an ASPX page by importing the namespace &
using the class name as the type

Imports Details
Public Class MyClass : Inherits Page
Public Enter1 As EnterCB
........
........
End Class

then I get the following error:

Type 'EnterCB' is not defined.

pointing to the line which declares the variable 'Enter1'.

I also compiled Enter.ascx.vb into a DLL in the bin directory
(Enter.ascx.vb not residing in the App_Code directory) & used the
CodeFile attribute in the @Control directive in the ascx file but this
generates the following error:

Make sure that the class defined in this code file matches the
'inherits' attribute, and that it extends the correct base class (e.g.
Page or UserControl).

which points to the

Imports System

line in Enter.ascx.vb. I have ensured both the conditions outlined in
the error message but I don't understand why the error persists.

It's better I adhere to the DLL in the bin directory without using the
CodeFile attribute in the @Control directive. The more I delve into
this, the more I am getting confused....
Karl Seguin wrote:
Actually, I'm about 90% sure that I'm right...did you give it a try?
it's
a
pretty simple fix to try and solve your problem...

The problem is that the ascx file expects to have access to the
Context
variable which is accessible as part of the UserControl class...

because you don't have a CodeFile, your ASCX file doesn't have any
codebehind associated with it...so there's no context...

It works when you drop a dll into the bin folder because the Inherits
kicks
in and now there IS a codebehind file for your class which does
inherit
from
UserControl so there IS a Context variable...

You're mixing CodeFile and Inherits...

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11**********************@j44g2000cwa.googleg roups.com...
Karl, I don't think that the absence of CodeFile is the cause of the
problem. You have replied to my post titled "App_Code & bin". VWD
behaves erratically in this case precisely because of the same
reason
i.e. if I relocate the code behind Enter.ascx.vb to some directory
other than the App_Code directory & then compile Enter.ascx.vb into
a
DLL in the bin directory using VBC, then VWD no longer displays the

'Context' is not a member of 'ASP.enter_ascx'

error when the mouse is moved over the line

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

in VWD but if I just have the code behind Enter.ascx.vb in the
App_Code
directory (& no DLL in the bin directory), then VWD shows the above
error when the mouse is hovered over the above line.

BTW, could you please explain me what does "Context" mean here?
Karl Seguin wrote:
I could be wrong, but shouldn't your @Control directive have a
CodeFile
attribute which points to the .vb file?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<rn**@rediffmail.comwrote in message
news:11*********************@l39g2000cwd.googlegr oups.com...
I have a user control named Enter.ascx which has 2 TextBoxes. The
2
TextBoxes are named txt1 & txt2. The entire logic of this user
control
(like the properties of the 2 TextBoxes using set/get etc.) is
encapsulated in a code behind page named Enter.ascx.vb. The
code-behind
also creates TextChanged events for the 2 TextBoxes. This is the
code
in Enter.ascx.vb:

Namespace Details
Public Class EnterCB : Inherits UserControl
Public WithEvents txt1 As TextBox
Public WithEvents txt2 As TextBox

'creating a few Properties for the
'2 TextBoxes using Set/Get

'create events for the 2 TextBoxes
Public Event TextChangedEvent(ByVal obj As Object, ByVal
ea
As
EventArgs)

Protected Sub txt1Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub

Protected Sub txt2Changed(ByVal obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChanged
RaiseEvent TextChangedEvent(obj, ea)
End Sub
End Class
End Namespace

This is how I am encompassing the above code behind in
Enter.ascx:

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

<asp:TextBox ID="txt1" runat="server"><br>
<asp:TextBox ID="txt2" runat="server">

As such the above user control when registered in an ASPX page
works
fine & even the Events associated with the 2 TextBoxes in the
user
control fire in the ASPX page when the text in the TextBoxes
change.

But Visual Web Developer 2005 Express Edition (which is what I
use
for
creating & editing ASP.NET apps) throws the following error

'Context' is not a member of 'ASP.enter_ascx'.

when the mouse is moved over the

<%@ Control Language="VB" Inherits="Details.EnterCB" %>

line in Enter.ascx. Now first of all, what does this error mean?
What
is 'Context' here? & secondly, why is VWD generating this error?
Nov 27 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Tim Martin | last post by:
Hi, I came across a detail in "C++ Gotchas" by Stephen Dewhurst that confused me a bit. The author states: 'C++ has no "methods." Java and Smalltalk have methods. When you talk about an...
13
by: Erik Haugen | last post by:
From reading gotw#84 (http://www.gotw.ca/gotw/084.htm), I'm convinced that I should try to make functions nonfriend nonmembers when practical, but then I came across this: Bruce Eckel says about...
3
by: Eddie de Bear | last post by:
Hi, A project I am working on has a requirement for dynamic menus. For the most part this works really well. The menus I'm creating a based on files and directories, so naturally the menu...
11
by: Roger Leigh | last post by:
The C++ book I have to hand (Liberty and Horvath, Teach yourself C++ for Linux in 21 Days--I know there are better) states that "static member functions cannot access any non-static member...
6
by: Murphy | last post by:
I've read through the google posts on this topic and am still unclear of the solution. Simply I have a user control that contains form controls and I would like to reference the values in the...
2
by: Bry | last post by:
I have a context menu which is shared between a TreeView and ListView control (both controls show the same information, similar to how Windows Explorer works, so it makes sense to use the same menu...
6
by: smmk25 | last post by:
Before I state the problem, I just want to let the readers know, I am knew to C++\CLI and interop so please forgive any newbie questions. I have a huge C library which I want to be able to use in...
2
by: jobs | last post by:
stupid question which I once think I had the answer to I'm sure. I create webform page with no codebehind. I then decide I want to create a codebehind for it. How can I do it so that it...
3
by: Chameleon | last post by:
The following code produces strange errors in mingw. Is a C++ problem or compiler problem? ---------------------------- #include <list> class A { static const int B = 0; std::list<intlst;...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.