Wednesday, March 28, 2012
Strange compilation errors
d
files. The corresponding class names are Defaul1 and Default2 respectively
and are in the same namespace (MyCompany.MyApplication.UI).
In the "Page_Load" of Page2 class I have the following code
if ( Context.Handler is Page1 )
Page1 sourcePage = (Page1)Context.Handler;
Not allways but quite often during the build, I see the following error:
The type or namespace name 'Page1' could not be found (are you missing a
using directive or an assembly reference?)
The error message appears twise indicating the two code lines above.
There is no missing "using" because both classes are in the same namespace.
There is no missing assemply reference because both classes (pages) are in
the same web project.
The dev environment is VS 2005 and in the code behind files the classes are
declared as partial.
Any ideas what could be the problem?
Thanksyou should not confuse namespaces with assemblies. namespace is just that, a
naming prefix. using a namespace just allows shortcuts in speciing names.
several assemblies (dlls) may use the same namespace, or one assembly may
have several namespaces. to reference a routine, you must specify the name,
but also must include the assembly containing the routine.
asp.net builds an assembly per page, so even though you use the same
namespace, you als need to add a reference to the page. a confusing facter
is that asp.net will compile serveral pages into the same dll if batching is
allowed. if you forgt the refernce and the pages end up in the same assembly
your ok. if they end up in different assemblies, then you're in trouble.
-- bruce (sqlwork.com)
"Argirop" <Argirop@.discussions.microsoft.com> wrote in message
news:8B674FC6-4D83-4D02-8076-1EA6D72E804E@.microsoft.com...
> Assuming two aspx pages named Defaul1 and Default2 whith separate code
> behind
> files. The corresponding class names are Defaul1 and Default2 respectively
> and are in the same namespace (MyCompany.MyApplication.UI).
> In the "Page_Load" of Page2 class I have the following code
> if ( Context.Handler is Page1 )
> Page1 sourcePage = (Page1)Context.Handler;
> Not allways but quite often during the build, I see the following error:
> The type or namespace name 'Page1' could not be found (are you missing a
> using directive or an assembly reference?)
> The error message appears twise indicating the two code lines above.
> There is no missing "using" because both classes are in the same
> namespace.
> There is no missing assemply reference because both classes (pages) are in
> the same web project.
> The dev environment is VS 2005 and in the code behind files the classes
> are
> declared as partial.
> Any ideas what could be the problem?
> Thanks
>
And how can I add a reference to Default1 in Default2 ?
"bruce barker (sqlwork.com)" wrote:
> you should not confuse namespaces with assemblies. namespace is just that,
a
> naming prefix. using a namespace just allows shortcuts in speciing names.
> several assemblies (dlls) may use the same namespace, or one assembly may
> have several namespaces. to reference a routine, you must specify the nam
e,
> but also must include the assembly containing the routine.
> asp.net builds an assembly per page, so even though you use the same
> namespace, you als need to add a reference to the page. a confusing facter
> is that asp.net will compile serveral pages into the same dll if batching
is
> allowed. if you forgt the refernce and the pages end up in the same assemb
ly
> your ok. if they end up in different assemblies, then you're in trouble.
> -- bruce (sqlwork.com)
> "Argirop" <Argirop@.discussions.microsoft.com> wrote in message
> news:8B674FC6-4D83-4D02-8076-1EA6D72E804E@.microsoft.com...
>
>
Never mind, I found it.
Thanks a lot.
"Argirop" wrote:
> And how can I add a reference to Default1 in Default2 ?
> "bruce barker (sqlwork.com)" wrote:
>
Strange compilation errors
files. The corresponding class names are Defaul1 and Default2 respectively
and are in the same namespace (MyCompany.MyApplication.UI).
In the "Page_Load" of Page2 class I have the following code
if ( Context.Handler is Page1 )
Page1 sourcePage = (Page1)Context.Handler;
Not allways but quite often during the build, I see the following error:
The type or namespace name 'Page1' could not be found (are you missing a
using directive or an assembly reference?)
The error message appears twise indicating the two code lines above.
There is no missing "using" because both classes are in the same namespace.
There is no missing assemply reference because both classes (pages) are in
the same web project.
The dev environment is VS 2005 and in the code behind files the classes are
declared as partial.
Any ideas what could be the problem?
Thanksyou should not confuse namespaces with assemblies. namespace is just that, a
naming prefix. using a namespace just allows shortcuts in speciing names.
several assemblies (dlls) may use the same namespace, or one assembly may
have several namespaces. to reference a routine, you must specify the name,
but also must include the assembly containing the routine.
asp.net builds an assembly per page, so even though you use the same
namespace, you als need to add a reference to the page. a confusing facter
is that asp.net will compile serveral pages into the same dll if batching is
allowed. if you forgt the refernce and the pages end up in the same assembly
your ok. if they end up in different assemblies, then you're in trouble.
-- bruce (sqlwork.com)
"Argirop" <Argirop@.discussions.microsoft.comwrote in message
news:8B674FC6-4D83-4D02-8076-1EA6D72E804E@.microsoft.com...
Quote:
Originally Posted by
Assuming two aspx pages named Defaul1 and Default2 whith separate code
behind
files. The corresponding class names are Defaul1 and Default2 respectively
and are in the same namespace (MyCompany.MyApplication.UI).
>
In the "Page_Load" of Page2 class I have the following code
>
if ( Context.Handler is Page1 )
Page1 sourcePage = (Page1)Context.Handler;
>
Not allways but quite often during the build, I see the following error:
>
The type or namespace name 'Page1' could not be found (are you missing a
using directive or an assembly reference?)
>
The error message appears twise indicating the two code lines above.
>
There is no missing "using" because both classes are in the same
namespace.
There is no missing assemply reference because both classes (pages) are in
the same web project.
>
The dev environment is VS 2005 and in the code behind files the classes
are
declared as partial.
>
Any ideas what could be the problem?
>
Thanks
>
>
And how can I add a reference to Default1 in Default2 ?
"bruce barker (sqlwork.com)" wrote:
Quote:
Originally Posted by
you should not confuse namespaces with assemblies. namespace is just that, a
naming prefix. using a namespace just allows shortcuts in speciing names.
several assemblies (dlls) may use the same namespace, or one assembly may
have several namespaces. to reference a routine, you must specify the name,
but also must include the assembly containing the routine.
>
asp.net builds an assembly per page, so even though you use the same
namespace, you als need to add a reference to the page. a confusing facter
is that asp.net will compile serveral pages into the same dll if batching is
allowed. if you forgt the refernce and the pages end up in the same assembly
your ok. if they end up in different assemblies, then you're in trouble.
>
-- bruce (sqlwork.com)
>
"Argirop" <Argirop@.discussions.microsoft.comwrote in message
news:8B674FC6-4D83-4D02-8076-1EA6D72E804E@.microsoft.com...
Quote:
Originally Posted by
Assuming two aspx pages named Defaul1 and Default2 whith separate code
behind
files. The corresponding class names are Defaul1 and Default2 respectively
and are in the same namespace (MyCompany.MyApplication.UI).
In the "Page_Load" of Page2 class I have the following code
if ( Context.Handler is Page1 )
Page1 sourcePage = (Page1)Context.Handler;
Not allways but quite often during the build, I see the following error:
The type or namespace name 'Page1' could not be found (are you missing a
using directive or an assembly reference?)
The error message appears twise indicating the two code lines above.
There is no missing "using" because both classes are in the same
namespace.
There is no missing assemply reference because both classes (pages) are in
the same web project.
The dev environment is VS 2005 and in the code behind files the classes
are
declared as partial.
Any ideas what could be the problem?
Thanks
>
>
>
Never mind, I found it.
Thanks a lot.
"Argirop" wrote:
Quote:
Originally Posted by
And how can I add a reference to Default1 in Default2 ?
>
"bruce barker (sqlwork.com)" wrote:
>
Quote:
Originally Posted by
you should not confuse namespaces with assemblies. namespace is just that, a
naming prefix. using a namespace just allows shortcuts in speciing names.
several assemblies (dlls) may use the same namespace, or one assembly may
have several namespaces. to reference a routine, you must specify the name,
but also must include the assembly containing the routine.
asp.net builds an assembly per page, so even though you use the same
namespace, you als need to add a reference to the page. a confusing facter
is that asp.net will compile serveral pages into the same dll if batching is
allowed. if you forgt the refernce and the pages end up in the same assembly
your ok. if they end up in different assemblies, then you're in trouble.
-- bruce (sqlwork.com)
"Argirop" <Argirop@.discussions.microsoft.comwrote in message
news:8B674FC6-4D83-4D02-8076-1EA6D72E804E@.microsoft.com...
Quote:
Originally Posted by
Assuming two aspx pages named Defaul1 and Default2 whith separate code
behind
files. The corresponding class names are Defaul1 and Default2 respectively
and are in the same namespace (MyCompany.MyApplication.UI).
>
In the "Page_Load" of Page2 class I have the following code
>
if ( Context.Handler is Page1 )
Page1 sourcePage = (Page1)Context.Handler;
>
Not allways but quite often during the build, I see the following error:
>
The type or namespace name 'Page1' could not be found (are you missing a
using directive or an assembly reference?)
>
The error message appears twise indicating the two code lines above.
>
There is no missing "using" because both classes are in the same
namespace.
There is no missing assemply reference because both classes (pages) are in
the same web project.
>
The dev environment is VS 2005 and in the code behind files the classes
are
declared as partial.
>
Any ideas what could be the problem?
>
Thanks
>
>
Monday, March 26, 2012
Strange Datagrid Update Problem
I'm having a strange problem with the update function of a datagrid:
I have a datagrid, the first column lists item names from a database.
Second column is an EditCommandColumn, and then I have a couple of
button columns after that to deal with row deletes etc.
The problem is occuring in the method that I have specified should
deal with the update event:
protected void nameEditUpdate(object sender, DataGridCommandEventArgs
e)
Because the first column I know contains the item that is getting
updated, I try:
tmpTextBox = (TextBox)e.Item.Cells[0].Controls[0];
To get the control, before looking at its Text property. However,
when I try this I get:
System.InvalidCastException: Specified cast is not valid.
So to try and figure out what is going on, I have tried looking at the
type being returned by e.Item.Cells[0].Controls[0], which turns out to
be type System.Web.UI.LiteralControl, the name and text properties of
it are blank. This has just confused me even more.
Anyone have any idea just what might be going on?
Appreciated!Use FindControl instead of hard coding the position in the Controls collection.
Otherwise iterate over the Controls collection until you find your TextBox
(I bet it's at position Controls[1]). What's happening is that there's whitespace
in your template after the <ItemTemplate> and before your <asp:TextBox> and
that's the LiteralControl you're seeing.
-Brock
DevelopMentor
http://staff.develop.com/ballen
> Hi,
> I'm having a strange problem with the update function of a datagrid:
> I have a datagrid, the first column lists item names from a database.
> Second column is an EditCommandColumn, and then I have a couple of
> button columns after that to deal with row deletes etc.
> The problem is occuring in the method that I have specified should
> deal with the update event:
> protected void nameEditUpdate(object sender, DataGridCommandEventArgs
> e)
> Because the first column I know contains the item that is getting
> updated, I try:
> tmpTextBox = (TextBox)e.Item.Cells[0].Controls[0];
> To get the control, before looking at its Text property. However,
> when I try this I get:
> System.InvalidCastException: Specified cast is not valid.
> So to try and figure out what is going on, I have tried looking at the
> type being returned by e.Item.Cells[0].Controls[0], which turns out to
> be type System.Web.UI.LiteralControl, the name and text properties of
> it are blank. This has just confused me even more.
> Anyone have any idea just what might be going on?
> Appreciated!
Thanks Brock. I would never have guessed that whitespace would be a
member of the controls collection!
On Sat, 11 Jun 2005 07:06:34 -0700, Brock Allen
<ballen@.NOSPAMdevelop.com> wrote:
>Use FindControl instead of hard coding the position in the Controls collection.
>Otherwise iterate over the Controls collection until you find your TextBox
>(I bet it's at position Controls[1]). What's happening is that there's whitespace
>in your template after the <ItemTemplate> and before your <asp:TextBox> and
>that's the LiteralControl you're seeing.
>-Brock
>DevelopMentor
>http://staff.develop.com/ballen