473,812 Members | 2,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'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 TextChangedEven t(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChange d
RaiseEvent TextChangedEven t(obj, ea)
End Sub

Protected Sub txt2Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChange d
RaiseEvent TextChangedEven t(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="Detai ls.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="Detai ls.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 29840
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**@rediffmai l.comwrote in message
news:11******** *************@l 39g2000cwd.goog legroups.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 TextChangedEven t(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChange d
RaiseEvent TextChangedEven t(obj, ea)
End Sub

Protected Sub txt2Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChange d
RaiseEvent TextChangedEven t(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="Detai ls.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="Detai ls.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="Detai ls.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**@rediffmai l.comwrote in message
news:11******** *************@l 39g2000cwd.goog legroups.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 TextChangedEven t(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChange d
RaiseEvent TextChangedEven t(obj, ea)
End Sub

Protected Sub txt2Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChange d
RaiseEvent TextChangedEven t(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="Detai ls.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="Detai ls.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.Htt pContext.Curren t".

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.Http Context.Current .

HttpContext ctx = HttpContext.Cur rent;


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**@rediffmai l.comwrote in message news:11******** **************@ j44g2000cwa.goo glegroups.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="Detai ls.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**@rediffma il.comwrote in message
news:11******* **************@ l39g2000cwd.goo glegroups.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 TextChangedEven t(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChange d
RaiseEvent TextChangedEven t(obj, ea)
End Sub

Protected Sub txt2Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChange d
RaiseEvent TextChangedEven t(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="Detai ls.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="Detai ls.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**@rediffmai l.comwrote in message
news:11******** **************@ j44g2000cwa.goo glegroups.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="Detai ls.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**@rediffma il.comwrote in message
news:11******* **************@ l39g2000cwd.goo glegroups.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 TextChangedEven t(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChange d
RaiseEvent TextChangedEven t(obj, ea)
End Sub

Protected Sub txt2Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChange d
RaiseEvent TextChangedEven t(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="Detai ls.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="Detai ls.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_C ode\Enter.ascx. vb"
Inherits="Detai ls.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**@rediffmai l.comwrote in message
news:11******** **************@ j44g2000cwa.goo glegroups.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="Detai ls.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**@rediffmai l.comwrote in message
news:11******** *************@l 39g2000cwd.goog legroups.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 TextChangedEven t(ByVal obj As Object, ByVal ea As
EventArgs)

Protected Sub txt1Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChange d
RaiseEvent TextChangedEven t(obj, ea)
End Sub

Protected Sub txt2Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChange d
RaiseEvent TextChangedEven t(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="Detai ls.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="Detai ls.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**@rediffmai l.comwrote in message
news:11******** **************@ j72g2000cwa.goo glegroups.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_C ode\Enter.ascx. vb"
Inherits="Detai ls.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**@rediffma il.comwrote in message
news:11******* *************** @j44g2000cwa.go oglegroups.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="Detai ls.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**@rediffma il.comwrote in message
news:11******* **************@ l39g2000cwd.goo glegroups.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 TextChangedEven t(ByVal obj As Object, ByVal ea
As
EventArgs)

Protected Sub txt1Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChange d
RaiseEvent TextChangedEven t(obj, ea)
End Sub

Protected Sub txt2Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChange d
RaiseEvent TextChangedEven t(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="Detai ls.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="Detai ls.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**@rediffmai l.comwrote in message
news:11******** **************@ j72g2000cwa.goo glegroups.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_C ode\Enter.ascx. vb"
Inherits="Detai ls.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**@rediffmai l.comwrote in message
news:11******** **************@ j44g2000cwa.goo glegroups.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="Detai ls.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**@rediffmai l.comwrote in message
news:11******** *************@l 39g2000cwd.goog legroups.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 TextChangedEven t(ByVal obj As Object, ByVal ea
As
EventArgs)

Protected Sub txt1Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChange d
RaiseEvent TextChangedEven t(obj, ea)
End Sub

Protected Sub txt2Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChange d
RaiseEvent TextChangedEven t(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="Detai ls.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="Detai ls.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...Howev er, 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...th is 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**@rediffmai l.comwrote in message
news:11******** **************@ 14g2000cws.goog legroups.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**@rediffma il.comwrote in message
news:11******* *************** @j72g2000cwa.go oglegroups.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_C ode\Enter.ascx. vb"
Inherits="Detai ls.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**@rediffma il.comwrote in message
news:11******* *************** @j44g2000cwa.go oglegroups.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="Detai ls.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**@rediffma il.comwrote in message
news:11******* **************@ l39g2000cwd.goo glegroups.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 TextChangedEven t(ByVal obj As Object, ByVal
ea
As
EventArgs)

Protected Sub txt1Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt1.TextChange d
RaiseEvent TextChangedEven t(obj, ea)
End Sub

Protected Sub txt2Changed(ByV al obj As Object, ByVal ea As
EventArgs) Handles txt2.TextChange d
RaiseEvent TextChangedEven t(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="Detai ls.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="Detai ls.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
8402
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 object-oriented design and are feeling particularly pretentious, you may use the terms "message" and "method," but when you get down to discussing a C++ implementation of your design, use the terms "function call" and "member function."'
13
2458
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 operator overloads in Thinking In C++ (2nd Ed - http://www.codeguru.com/cpp/tic/tic0129.shtml) "In general, if it doesn't make any difference, they should be members, to emphasize the association between the operator and its class." That seems...
3
4780
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 creation takes some time. The approach I took was to override the OnSelect method of the MenuItem class, which had code to populate the
11
4631
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 variables". However, this doesn't seem entirely correct. It also doesn't mention whether static member functions can access protected and private member data and methods (and I couldn't spot this in the FAQ). I have a class row<Row> which derives from...
6
8676
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 form from the aspx page that contains the user control. The error message received is: Compiler Error Message: BC30390: 'ASP._userdetails_ascx.Company' is not accessible in this context because it is 'Protected'. Thanks
2
23120
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 on both views). What i'm struggling to do when the menuItem_Click event is fired, is to detect the TreeNode or ListViewItem that was originally right clicked when the context menu was opened. I can't just look at the selected item, because...
6
7685
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 a .NET application and thus am looking into writing a managed C++ wrapper for in vs2005. Furthermore, this library has many callback hooks which need to be implemented by the C++ wrapper. These callback functions are declared as "extern C...
2
5656
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 falls under the aspx page and does give met hat context error> I tried creating the .vb file, and making sure the directive on the
3
3114
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; void calc();
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10417
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10139
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9219
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7677
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4357
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.