473,322 Members | 1,494 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.

WebAppication project doesn't like separate codefiles

Hi,

I have in my web application project (VS.NET 2008) :
- a webform (webform2.aspx, webform2.aspx.cs,
webform2.aspx.designer.cs)
- a code-file Product.cs.

But i can't use the definition of 'Product' nowhere in my page-class-
file (webform2.aspx.cs)

For example:

protected void Page_Load(object sender, EventArgs e)
{
Product p = new Product();
}

the compiler doesn't know the definition of Product

whereas if I place the definition of Product in the same codefile as
the WebForm.cs then it works.

How can i make it work just by keeping each class definition in its
own codefile?
By the way, what happened to the App_Code used in 2005?

thank you
Chris
Aug 1 '08 #1
20 1519
<cm****@gmail.comwrote in message
news:39**********************************@a1g2000h sb.googlegroups.com...
Hi,

I have in my web application project (VS.NET 2008) :
- a webform (webform2.aspx, webform2.aspx.cs,
webform2.aspx.designer.cs)
- a code-file Product.cs.

But i can't use the definition of 'Product' nowhere in my page-class-
file (webform2.aspx.cs)

For example:

protected void Page_Load(object sender, EventArgs e)
{
Product p = new Product();
}

the compiler doesn't know the definition of Product

whereas if I place the definition of Product in the same codefile as
the WebForm.cs then it works.

How can i make it work just by keeping each class definition in its
own codefile?
By the way, what happened to the App_Code used in 2005?
If App_Code isn't there its because it hasn't been created yet. App_Code is
where your Product.cs should be. I would recommend you use a namespace as
well the word 'Product' is fairly common.
--
Anthony Jones - MVP ASP/ASP.NET
Aug 1 '08 #2
I concur with App_Code, if not in its own assembly. If that is not to your
liking, make sure you have the proper namespace referenced in your code
behind/beside file.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
<cm****@gmail.comwrote in message
news:39**********************************@a1g2000h sb.googlegroups.com...
Hi,

I have in my web application project (VS.NET 2008) :
- a webform (webform2.aspx, webform2.aspx.cs,
webform2.aspx.designer.cs)
- a code-file Product.cs.

But i can't use the definition of 'Product' nowhere in my page-class-
file (webform2.aspx.cs)

For example:

protected void Page_Load(object sender, EventArgs e)
{
Product p = new Product();
}

the compiler doesn't know the definition of Product

whereas if I place the definition of Product in the same codefile as
the WebForm.cs then it works.

How can i make it work just by keeping each class definition in its
own codefile?
By the way, what happened to the App_Code used in 2005?

thank you
Chris
Aug 1 '08 #3
On Aug 1, 7:39 pm, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
I concur with App_Code, if not in its own assembly. If that is not to your
liking, make sure you have the proper namespace referenced in your code
behind/beside file.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my bloghttp://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************<cmr.. .@gmail.comwrote in message

news:39**********************************@a1g2000h sb.googlegroups.com...
Hi,
I have in my web application project (VS.NET 2008) :
- a webform (webform2.aspx, webform2.aspx.cs,
webform2.aspx.designer.cs)
- a code-file Product.cs.
But i can't use the definition of 'Product' nowhere in my page-class-
file (webform2.aspx.cs)
For example:
protected void Page_Load(object sender, EventArgs e)
{
Product p = new Product();
}
the compiler doesn't know the definition of Product
whereas if I place the definition of Product in the same codefile as
the WebForm.cs then it works.
How can i make it work just by keeping each class definition in its
own codefile?
By the way, what happened to the App_Code used in 2005?
thank you
Chris
hello,

actually I previously put the code in App_Code, but even then it
doesn't work !
Only when I use it inline it works, but not when placed in the code-
behind file ???

So, the following works:
<script runat="server">
void Button1_Click(object sender, EventArgs e)
{
Product c = new Product();
Label1.Text = c.GetMyMessage(TextBox1.Text);
}
</script>

but not in the code-behind file, how come?

why doesn't it work the 'normal' way, I mean with the code-files in
the same directory as the aspx-file (it works like that in WinForms)
Or is there a way?

thank you
Aug 1 '08 #4
Do you have a line like this, to import the code-behaind class ?

<%@ Page Language="C#" AutoEventWireup="false" CodeFile="some.aspx.cs" Inherits="_some" %>


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/
======================================

<cm****@gmail.comwrote in message news:7c**********************************@a70g2000 hsh.googlegroups.com...
On Aug 1, 7:39 pm, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
>I concur with App_Code, if not in its own assembly. If that is not to your
liking, make sure you have the proper namespace referenced in your code
behind/beside file.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my bloghttp://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************<cmr. ..@gmail.comwrote in message

news:39**********************************@a1g2000 hsb.googlegroups.com...
Hi,
I have in my web application project (VS.NET 2008) :
- a webform (webform2.aspx, webform2.aspx.cs,
webform2.aspx.designer.cs)
- a code-file Product.cs.
But i can't use the definition of 'Product' nowhere in my page-class-
file (webform2.aspx.cs)
For example:
protected void Page_Load(object sender, EventArgs e)
{
Product p = new Product();
}
the compiler doesn't know the definition of Product
whereas if I place the definition of Product in the same codefile as
the WebForm.cs then it works.
How can i make it work just by keeping each class definition in its
own codefile?
By the way, what happened to the App_Code used in 2005?
thank you
Chris

hello,

actually I previously put the code in App_Code, but even then it
doesn't work !
Only when I use it inline it works, but not when placed in the code-
behind file ???

So, the following works:
<script runat="server">
void Button1_Click(object sender, EventArgs e)
{
Product c = new Product();
Label1.Text = c.GetMyMessage(TextBox1.Text);
}
</script>

but not in the code-behind file, how come?

why doesn't it work the 'normal' way, I mean with the code-files in
the same directory as the aspx-file (it works like that in WinForms)
Or is there a way?

thank you


Aug 1 '08 #5
On Aug 1, 8:40 pm, "Juan T. Llibre" <nomailrepl...@nowhere.comwrote:
Do you have a line like this, to import the code-behaind class ?

<%@ Page Language="C#" AutoEventWireup="false" CodeFile="some.aspx.cs" Inherits="_some" %>

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/
======================================

<cmr...@gmail.comwrote in messagenews:7c**********************************@a 70g2000hsh.googlegroups.com...
On Aug 1, 7:39 pm, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
I concur with App_Code, if not in its own assembly. If that is not to your
liking, make sure you have the proper namespace referenced in your code
behind/beside file.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my bloghttp://gregorybeamer.spaces.live.com/lists/feed.rss
or just read it:http://gregorybeamer.spaces.live.com/
********************************************
| Think outside the box! |
********************************************<cmr.. .@gmail.comwrote in message
>news:39**********************************@a1g2000 hsb.googlegroups.com....
Hi,
I have in my web application project (VS.NET 2008) :
- a webform (webform2.aspx, webform2.aspx.cs,
webform2.aspx.designer.cs)
- a code-file Product.cs.
But i can't use the definition of 'Product' nowhere in my page-class-
file (webform2.aspx.cs)
For example:
protected void Page_Load(object sender, EventArgs e)
{
Product p = new Product();
}
the compiler doesn't know the definition of Product
whereas if I place the definition of Product in the same codefile as
the WebForm.cs then it works.
How can i make it work just by keeping each class definition in its
own codefile?
By the way, what happened to the App_Code used in 2005?
thank you
Chris
hello,
actually I previously put the code in App_Code, but even then it
doesn't work !
Only when I use it inline it works, but not when placed in the code-
behind file ???
So, the following works:
<script runat="server">
void Button1_Click(object sender, EventArgs e)
{
Product c = new Product();
Label1.Text = c.GetMyMessage(TextBox1.Text);
}
</script>
but not in the code-behind file, how come?
why doesn't it work the 'normal' way, I mean with the code-files in
the same directory as the aspx-file (it works like that in WinForms)
Or is there a way?
thank you
hello,

yes i do ... in the webApp-directory I have a file
BindingToDataAccessLayer.aspx starting with
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="BindingToDataAccessLayer.aspx.cs"
Inherits="WebForm1" %>

in BindingToDataAccessLayer.aspx.cs I have:

using Products; // --COMPILER ERROR: namespace name could not
be found
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Product p = new Product(); // --COMPILER ERROR
}
}
for the rest of my project structure:

In App_Code i have Product.cs

namespace Products
{
public class Product
{ ...}
}

it just doesn't make sense to me
any suggestions?

Chris
Aug 1 '08 #6
re:
!in the webApp-directory I have a file BindingToDataAccessLayer.aspx starting with:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="..." Inherits="WebForm1" %>

Please recheck that the Class in "BindingToDataAccessLayer.aspx.cs" is actually named "WebForm1".

VS 2008 follows this type of class naming syntax in code-behind files:

In default.aspx.cs, the code-behind page for Default.aspx...
public partial class _Default : System.Web.UI.Page

Notice the underscore, and notice that the page's class
is named for the page name, with an underscore added.

It looks to me like like renamed an aspx page, but did not change the class name in the code-behind.

The IDE does not automatically change the class name for you if you rename a file.
If you ask me, I think it should... :-)

In any case, for a page named "BindingToDataAccessLayer.aspx.cs",
this is the default syntax the IDE uses when creating the page and its code-behind class:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BindingToDataAccessLayer.aspx.cs"
Inherits="_BindingToDataAccessLayer" %>

Your class can be named anything you want to,
but the Inherits statement must point to the correct class name.


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/
======================================
<cm****@gmail.comwrote in message news:6b**********************************@8g2000hs e.googlegroups.com...
On Aug 1, 8:40 pm, "Juan T. Llibre" <nomailrepl...@nowhere.comwrote:
Do you have a line like this, to import the code-behaind class ?

<%@ Page Language="C#" AutoEventWireup="false" CodeFile="some.aspx.cs" Inherits="_some" %>

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/
======================================

<cmr...@gmail.comwrote in messagenews:7c**********************************@a 70g2000hsh.googlegroups.com...
On Aug 1, 7:39 pm, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
I concur with App_Code, if not in its own assembly. If that is not to your
liking, make sure you have the proper namespace referenced in your code
behind/beside file.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my bloghttp://gregorybeamer.spaces.live.com/lists/feed.rss
or just read it:http://gregorybeamer.spaces.live.com/
********************************************
| Think outside the box! |
********************************************<cmr.. .@gmail.comwrote in message
>news:39**********************************@a1g2000 hsb.googlegroups.com...
Hi,
I have in my web application project (VS.NET 2008) :
- a webform (webform2.aspx, webform2.aspx.cs,
webform2.aspx.designer.cs)
- a code-file Product.cs.
But i can't use the definition of 'Product' nowhere in my page-class-
file (webform2.aspx.cs)
For example:
protected void Page_Load(object sender, EventArgs e)
{
Product p = new Product();
}
the compiler doesn't know the definition of Product
whereas if I place the definition of Product in the same codefile as
the WebForm.cs then it works.
How can i make it work just by keeping each class definition in its
own codefile?
By the way, what happened to the App_Code used in 2005?
thank you
Chris
hello,
actually I previously put the code in App_Code, but even then it
doesn't work !
Only when I use it inline it works, but not when placed in the code-
behind file ???
So, the following works:
<script runat="server">
void Button1_Click(object sender, EventArgs e)
{
Product c = new Product();
Label1.Text = c.GetMyMessage(TextBox1.Text);
}
</script>
but not in the code-behind file, how come?
why doesn't it work the 'normal' way, I mean with the code-files in
the same directory as the aspx-file (it works like that in WinForms)
Or is there a way?
thank you
hello,

yes i do ... in the webApp-directory I have a file
BindingToDataAccessLayer.aspx starting with
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="BindingToDataAccessLayer.aspx.cs"
Inherits="WebForm1" %>

in BindingToDataAccessLayer.aspx.cs I have:

using Products; // --COMPILER ERROR: namespace name could not
be found
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Product p = new Product(); // --COMPILER ERROR
}
}
for the rest of my project structure:

In App_Code i have Product.cs

namespace Products
{
public class Product
{ ...}
}

it just doesn't make sense to me
any suggestions?

Chris

Aug 2 '08 #7
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
VS 2008 follows this type of class naming syntax in code-behind files:

In default.aspx.cs, the code-behind page for Default.aspx...
public partial class _Default : System.Web.UI.Page

Notice the underscore, and notice that the page's class
is named for the page name, with an underscore added.
Also, the upper-case "D", C# being case-sensitive...
It looks to me like like renamed an aspx page, but did not change the
class name in the code-behind.
Indeed. I've been caught out with that on more than one occasion... :-)
The IDE does not automatically change the class name for you if you rename
a file.
If you ask me, I think it should... :-)
I agree or, at the very least, pop a warning to say that there is now a
"mismatch" (for want of a better term) between the class name specified in
the page's @Page directive and the actual partial class specified in its
associated code-behind file...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 2 '08 #8
On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"Juan T. Llibre" <nomailrepl...@nowhere.comwrote in messagenews:eu**************@TK2MSFTNGP02.phx.gbl. ..
VS 2008 follows this type of class naming syntax in code-behind files:
In default.aspx.cs, the code-behind page for Default.aspx...
public partial class _Default : System.Web.UI.Page
Notice the underscore, and notice that the page's class
is named for the page name, with an underscore added.

Also, the upper-case "D", C# being case-sensitive...
It looks to me like like renamed an aspx page, but did not change the
class name in the code-behind.

Indeed. I've been caught out with that on more than one occasion... :-)
The IDE does not automatically change the class name for you if you rename
a file.
If you ask me, I think it should... :-)

I agree or, at the very least, pop a warning to say that there is now a
"mismatch" (for want of a better term) between the class name specified in
the page's @Page directive and the actual partial class specified in its
associated code-behind file...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
the class has the same name as specified by inherits

in BindingToDataAccessLayer.aspx I have:

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="BindingToDataAccessLayer.aspx.cs"
Inherits="WebForm1" %>

and in BindingToDataAccessLayer.aspx.cs I have:

public partial class WebForm1 : System.Web.UI.Page
{ }

if the 2 didn't match, suppose I define WebForm2 in the code behind
file but leave Inherits="WebForm1", I'd get an error in the browser
anyway when starting up
--'WebForm1' is not allowed here because it does not extend
class 'System.Web.UI.Page'.

I'm running out of options :-((

any suggestions?

Chris
Aug 2 '08 #9
On Aug 2, 7:14 am, cmr...@gmail.com wrote:
On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"Juan T. Llibre" <nomailrepl...@nowhere.comwrote in messagenews:eu**************@TK2MSFTNGP02.phx.gbl. ..
VS 2008 follows this type of class naming syntax in code-behind files:
In default.aspx.cs, the code-behind page for Default.aspx...
public partial class _Default : System.Web.UI.Page
Notice the underscore, and notice that the page's class
is named for the page name, with an underscore added.
Also, the upper-case "D", C# being case-sensitive...
It looks to me like like renamed an aspx page, but did not change the
class name in the code-behind.
Indeed. I've been caught out with that on more than one occasion... :-)
The IDE does not automatically change the class name for you if you rename
a file.
If you ask me, I think it should... :-)
I agree or, at the very least, pop a warning to say that there is now a
"mismatch" (for want of a better term) between the class name specified in
the page's @Page directive and the actual partial class specified in its
associated code-behind file...
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

the class has the same name as specified by inherits

in BindingToDataAccessLayer.aspx I have:

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="BindingToDataAccessLayer.aspx.cs"
Inherits="WebForm1" %>

and in BindingToDataAccessLayer.aspx.cs I have:

public partial class WebForm1 : System.Web.UI.Page
{ }

if the 2 didn't match, suppose I define WebForm2 in the code behind
file but leave Inherits="WebForm1", I'd get an error in the browser
anyway when starting up
--'WebForm1' is not allowed here because it does not extend
class 'System.Web.UI.Page'.

I'm running out of options :-((

any suggestions?

Chris
Okay, this may be a totally useless suggestion, especially since
you're using in VS 2008, and my experience is with VS 2005, but...
Are you sure the product class is being compiled?
When I did a WebApplication in VS2005, and put classes in App_Code, I
had a problem where I simply could not see them in the rest of the
program. Even if I moved them to the root, I still couldn't see them.
I finally introduced deliberate syntax errors into the class, and then
did a Build, and the errors were not caught, thus convincing myself
that the files were not being included in the build.

I think the problem turned out to be (again, this may not apply to VS
2008) if you click a .cs file in the Solution explorer and look at the
Properties page for it, the first line there is "Build Action". For
the files I created in App_Code, it was set to "Content" instead of
"Compile", and it remained that way even if I moved the file.

Hope I didn't waste your time, but it might be worth looking at.
Aug 2 '08 #10
What happens if you fully qualify the class name :

Inherits="YourNamespace.WebForm1"

?

i.e., if your namespace is named WebApp :

Inherits="WebApp.WebForm1"

This should do it IF you are using a namespace in your codebehind...which you should, anyway :

namespace WebApp
{
public partial class WebForm1 : System.Web.UI.Page


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/
======================================

<cm****@gmail.comwrote in message news:96**********************************@m73g2000 hsh.googlegroups.com...
On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
>"Juan T. Llibre" <nomailrepl...@nowhere.comwrote in messagenews:eu**************@TK2MSFTNGP02.phx.gbl. ..
VS 2008 follows this type of class naming syntax in code-behind files:
In default.aspx.cs, the code-behind page for Default.aspx...
public partial class _Default : System.Web.UI.Page
Notice the underscore, and notice that the page's class
is named for the page name, with an underscore added.

Also, the upper-case "D", C# being case-sensitive...
It looks to me like like renamed an aspx page, but did not change the
class name in the code-behind.

Indeed. I've been caught out with that on more than one occasion... :-)
The IDE does not automatically change the class name for you if you rename
a file.
If you ask me, I think it should... :-)

I agree or, at the very least, pop a warning to say that there is now a
"mismatch" (for want of a better term) between the class name specified in
the page's @Page directive and the actual partial class specified in its
associated code-behind file...

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
>
the class has the same name as specified by inherits

in BindingToDataAccessLayer.aspx I have:

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="BindingToDataAccessLayer.aspx.cs"
Inherits="WebForm1" %>

and in BindingToDataAccessLayer.aspx.cs I have:

public partial class WebForm1 : System.Web.UI.Page
{ }

if the 2 didn't match, suppose I define WebForm2 in the code behind
file but leave Inherits="WebForm1", I'd get an error in the browser
anyway when starting up
--'WebForm1' is not allowed here because it does not extend
class 'System.Web.UI.Page'.

I'm running out of options :-((

any suggestions?

Chris

Aug 2 '08 #11
On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"Juan T. Llibre" <nomailrepl...@nowhere.comwrote in messagenews:eu**************@TK2MSFTNGP02.phx.gbl. ..
VS 2008 follows this type of class naming syntax in code-behind files:
In default.aspx.cs, the code-behind page for Default.aspx...
public partial class _Default : System.Web.UI.Page
Notice the underscore, and notice that the page's class
is named for the page name, with an underscore added.

Also, the upper-case "D", C# being case-sensitive...
It looks to me like like renamed an aspx page, but did not change the
class name in the code-behind.

Indeed. I've been caught out with that on more than one occasion... :-)
The IDE does not automatically change the class name for you if you rename
a file.
If you ask me, I think it should... :-)

I agree or, at the very least, pop a warning to say that there is now a
"mismatch" (for want of a better term) between the class name specified in
the page's @Page directive and the actual partial class specified in its
associated code-behind file...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
no difference :-(

There was no namespace so it wasn't necessary but I've defined the
class in a namespace now

namespace MyNs
{
public partial class WebForm1 : System.Web.UI.Page
{
}
}

Inherits="MyNs.WebForm1"

but still nothing :-(

anyway ... as the best design still is a separate controlLib for each
tier-component I think I'll leave it at that. unless you have another
option ?

i was just curious about this App_Code thing but as you can imagine,
I'm not impressed at all by that functionality..
my experience with it? a waste of time.
what is supposed the benefit of it?
I can only use my product-class when using it in inline script in the
aspx-file, so why come up then with the idea of code-behind in the
first place?

Chris
Aug 2 '08 #12
re:
!i was just curious about this App_Code thing but as you can imagine,
!I'm not impressed at all by that functionality..

Quite frankly, I'm not too impressed with it, either, primarily from a security viewpoint.
Uploading raw code to a server isn't a very secure approach to programming.

Also, there's no problems like the one you're encountering.

re:
!I can only use my product-class when using it in inline script in the aspx-file,
!so why come up then with the idea of code-behind in the first place?

I've evolved a personal preference which skirts the issues :

I compile assemblies with my helper classes ( my DAL layer ) from the command-line,
and place the resulting assembly in the /bin directory.

It's quite easy then to import my namespace with

<%@ Import Namespace="DataObjects" %>

....and instantiating the SQLDATA class is uncomplicated with :

Dim RS as New SQLDATA()

It works 100% of the time with no fuss.

I'd recommend ( depending on your time availability )
you dump what you're doing now...and create your own Data Access Layer (DAL).

Here's two pages with sample code which will help you get that done quickly :

http://msdn.microsoft.com/en-us/library/aa581778.aspx

http://weblogs.asp.net/scottgu/archi...15/435498.aspx


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/
======================================
<cm****@gmail.comwrote in message news:47**********************************@l64g2000 hse.googlegroups.com...
On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
>"Juan T. Llibre" <nomailrepl...@nowhere.comwrote in messagenews:eu**************@TK2MSFTNGP02.phx.gbl. ..
VS 2008 follows this type of class naming syntax in code-behind files:
In default.aspx.cs, the code-behind page for Default.aspx...
public partial class _Default : System.Web.UI.Page
Notice the underscore, and notice that the page's class
is named for the page name, with an underscore added.

Also, the upper-case "D", C# being case-sensitive...
It looks to me like like renamed an aspx page, but did not change the
class name in the code-behind.

Indeed. I've been caught out with that on more than one occasion... :-)
The IDE does not automatically change the class name for you if you rename
a file.
If you ask me, I think it should... :-)

I agree or, at the very least, pop a warning to say that there is now a
"mismatch" (for want of a better term) between the class name specified in
the page's @Page directive and the actual partial class specified in its
associated code-behind file...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

no difference :-(

There was no namespace so it wasn't necessary but I've defined the
class in a namespace now

namespace MyNs
{
public partial class WebForm1 : System.Web.UI.Page
{
}
}

Inherits="MyNs.WebForm1"

but still nothing :-(

anyway ... as the best design still is a separate controlLib for each
tier-component I think I'll leave it at that. unless you have another
option ?

i was just curious about this App_Code thing but as you can imagine,
I'm not impressed at all by that functionality..
my experience with it? a waste of time.
what is supposed the benefit of it?
I can only use my product-class when using it in inline script in the
aspx-file, so why come up then with the idea of code-behind in the
first place?

Chris

Aug 2 '08 #13
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:O%****************@TK2MSFTNGP03.phx.gbl...
I've evolved a personal preference which skirts the issues :
FWIW, I do virtually the same - in fact, I may have pinched the idea from
you in the first place... ;-)
I'd recommend ( depending on your time availability )
you dump what you're doing now...and create your own Data Access Layer
(DAL).
I couldn't agree more!

And dump all the SqlDataSource / ObjectDataSource hand-holding stuff at the
same time...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 2 '08 #14
On Aug 2, 4:55 pm, "Juan T. Llibre" <nomailrepl...@nowhere.comwrote:
re:
!i was just curious about this App_Code thing but as you can imagine,
!I'm not impressed at all by that functionality..

Quite frankly, I'm not too impressed with it, either, primarily from a security viewpoint.
Uploading raw code to a server isn't a very secure approach to programming.

Also, there's no problems like the one you're encountering.

re:
!I can only use my product-class when using it in inline script in the aspx-file,
!so why come up then with the idea of code-behind in the first place?

I've evolved a personal preference which skirts the issues :

I compile assemblies with my helper classes ( my DAL layer ) from the command-line,
and place the resulting assembly in the /bin directory.

It's quite easy then to import my namespace with

<%@ Import Namespace="DataObjects" %>

...and instantiating the SQLDATA class is uncomplicated with :

Dim RS as New SQLDATA()

It works 100% of the time with no fuss.

I'd recommend ( depending on your time availability )
you dump what you're doing now...and create your own Data Access Layer (DAL).

Here's two pages with sample code which will help you get that done quickly :

http://msdn.microsoft.com/en-us/library/aa581778.aspx

http://weblogs.asp.net/scottgu/archi...15/435498.aspx

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/
======================================

<cmr...@gmail.comwrote in messagenews:47**********************************@l 64g2000hse.googlegroups.com...
On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"Juan T. Llibre" <nomailrepl...@nowhere.comwrote in messagenews:eu**************@TK2MSFTNGP02.phx.gbl. ..
VS 2008 follows this type of class naming syntax in code-behind files:
In default.aspx.cs, the code-behind page for Default.aspx...
public partial class _Default : System.Web.UI.Page
Notice the underscore, and notice that the page's class
is named for the page name, with an underscore added.
Also, the upper-case "D", C# being case-sensitive...
It looks to me like like renamed an aspx page, but did not change the
class name in the code-behind.
Indeed. I've been caught out with that on more than one occasion... :-)
The IDE does not automatically change the class name for you if you rename
a file.
If you ask me, I think it should... :-)
I agree or, at the very least, pop a warning to say that there is now a
"mismatch" (for want of a better term) between the class name specified in
the page's @Page directive and the actual partial class specified in its
associated code-behind file...
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
no difference :-(
There was no namespace so it wasn't necessary but I've defined the
class in a namespace now
namespace MyNs
{
public partial class WebForm1 : System.Web.UI.Page
{
}
}
Inherits="MyNs.WebForm1"
but still nothing :-(
anyway ... as the best design still is a separate controlLib for each
tier-component I think I'll leave it at that. unless you have another
option ?
i was just curious about this App_Code thing but as you can imagine,
I'm not impressed at all by that functionality..
my experience with it? a waste of time.
what is supposed the benefit of it?
I can only use my product-class when using it in inline script in the
aspx-file, so why come up then with the idea of code-behind in the
first place?
Chris
thank you!

Chris
Aug 2 '08 #15
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:O%****************@TK2MSFTNGP03.phx.gbl...
re:
!i was just curious about this App_Code thing but as you can imagine,
!I'm not impressed at all by that functionality..

Quite frankly, I'm not too impressed with it, either, primarily from a
security viewpoint.
Uploading raw code to a server isn't a very secure approach to
programming.
>
Also, there's no problems like the one you're encountering.

re:
!I can only use my product-class when using it in inline script in the
aspx-file,
!so why come up then with the idea of code-behind in the first place?

I've evolved a personal preference which skirts the issues :

I compile assemblies with my helper classes ( my DAL layer ) from the
command-line,
and place the resulting assembly in the /bin directory.

It's quite easy then to import my namespace with

<%@ Import Namespace="DataObjects" %>

...and instantiating the SQLDATA class is uncomplicated with :

Dim RS as New SQLDATA()

It works 100% of the time with no fuss.

I'd recommend ( depending on your time availability )
you dump what you're doing now...and create your own Data Access Layer
(DAL).
>
Here's two pages with sample code which will help you get that done
quickly :
>
http://msdn.microsoft.com/en-us/library/aa581778.aspx

http://weblogs.asp.net/scottgu/archi...15/435498.aspx

Can't say I've ever seen these problems myself. App_Code has always worked
IMO experience and thats across quite a number of clients. Unless you are
being really fussy with strong names etc being App_Code is no less secure
than the bin directory. I don't put any of my code there myself but
customers use it. Its easy and 'fudgeable' (there is no need to build dlls
to make a minor tweak).

So far I have found the code that starts off in App_Code migrates to the bin
once it has been established.

--
Anthony Jones - MVP ASP/ASP.NET
Aug 4 '08 #16
re:
!App_Code is no less secure than the bin directory

I'll take a strong exception to that...

re:
!I don't put any of my code there myself

Why ?

re:
!So far I have found the code that starts off in App_Code
!migrates to the bin once it has been established.

Sure, it does, but your source code also stays in App_Code
where any two-bit programmer in your organization can see it.

I prefer to not upload source code...and obfuscate my assemblies.
Ymmv...


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/
======================================
"Anthony Jones" <An*@yadayadayada.comwrote in message news:eR**************@TK2MSFTNGP06.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:O%****************@TK2MSFTNGP03.phx.gbl...
>re:
!i was just curious about this App_Code thing but as you can imagine,
!I'm not impressed at all by that functionality..

Quite frankly, I'm not too impressed with it, either, primarily from a
security viewpoint.
>Uploading raw code to a server isn't a very secure approach to
programming.
>>
Also, there's no problems like the one you're encountering.

re:
!I can only use my product-class when using it in inline script in the
aspx-file,
>!so why come up then with the idea of code-behind in the first place?

I've evolved a personal preference which skirts the issues :

I compile assemblies with my helper classes ( my DAL layer ) from the
command-line,
>and place the resulting assembly in the /bin directory.

It's quite easy then to import my namespace with

<%@ Import Namespace="DataObjects" %>

...and instantiating the SQLDATA class is uncomplicated with :

Dim RS as New SQLDATA()

It works 100% of the time with no fuss.

I'd recommend ( depending on your time availability )
you dump what you're doing now...and create your own Data Access Layer
(DAL).
>>
Here's two pages with sample code which will help you get that done
quickly :
>>
http://msdn.microsoft.com/en-us/library/aa581778.aspx

http://weblogs.asp.net/scottgu/archi...15/435498.aspx


Can't say I've ever seen these problems myself. App_Code has always worked
IMO experience and thats across quite a number of clients. Unless you are
being really fussy with strong names etc being App_Code is no less secure
than the bin directory. I don't put any of my code there myself but
customers use it. Its easy and 'fudgeable' (there is no need to build dlls
to make a minor tweak).

So far I have found the code that starts off in App_Code migrates to the bin
once it has been established.

--
Anthony Jones - MVP ASP/ASP.NET


Aug 5 '08 #17
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:eS**************@TK2MSFTNGP05.phx.gbl...
re:
!App_Code is no less secure than the bin directory

I'll take a strong exception to that...
Why? Do you think it isn't true?
>
re:
!I don't put any of my code there myself

Why ?
I just don't ;)
>
re:
!So far I have found the code that starts off in App_Code
!migrates to the bin once it has been established.

Sure, it does, but your source code also stays in App_Code
where any two-bit programmer in your organization can see it.
We don't employ two-bit programmers. Besides a two-bit programmer can still
manage to compile a dll and drop it in the bin.

--
Anthony Jones - MVP ASP/ASP.NET
Aug 6 '08 #18
re:
!>>App_Code is no less secure than the bin directory
!>I'll take a strong exception to that...
!Why? Do you think it isn't true?

Anthony, you're rationalizing insecure procedures.

Name me *one* programmer who prefers to place raw source code
a server...and I'll show you a severely complacent person who's likely
to get the jolt of his life when his precious code is lifted.

re:
!>>I don't put any of my code there myself
!>Why ?
!I just don't ;)

So, you *do* agree with me.

re:
!Besides a two-bit programmer can still manage to compile a dll and drop it in the bin

Where the code will be a lot safer than if uploaded raw.

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/
======================================
"Anthony Jones" <An*@yadayadayada.comwrote in message news:ux****************@TK2MSFTNGP06.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:eS**************@TK2MSFTNGP05.phx.gbl...
>re:
!App_Code is no less secure than the bin directory

I'll take a strong exception to that...

Why? Do you think it isn't true?
>>
re:
!I don't put any of my code there myself

Why ?

I just don't ;)
>>
re:
!So far I have found the code that starts off in App_Code
!migrates to the bin once it has been established.

Sure, it does, but your source code also stays in App_Code
where any two-bit programmer in your organization can see it.
We don't employ two-bit programmers. Besides a two-bit programmer can still
manage to compile a dll and drop it in the bin.

--
Anthony Jones - MVP ASP/ASP.NET


Aug 6 '08 #19
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
re:
!>>App_Code is no less secure than the bin directory
!>I'll take a strong exception to that...
!Why? Do you think it isn't true?

Anthony, you're rationalizing insecure procedures.

Name me *one* programmer who prefers to place raw source code
a server...and I'll show you a severely complacent person who's likely
to get the jolt of his life when his precious code is lifted.

re:
!>>I don't put any of my code there myself
!>Why ?
!I just don't ;)

So, you *do* agree with me.

re:
!Besides a two-bit programmer can still manage to compile a dll and drop
it in the bin
>
Where the code will be a lot safer than if uploaded raw.
I think we're talking at cross purposes. I hadn't considered that by
security you were refering to protecting your source code as an asset. I
was thinking of security in terms of a black hat doing something malicious
to site. If such a person has access to the App_Code they have access to
the bin and in fact the whole site.

Still there are times when source isn't particularly valueable as an asset
and its accessibility to customers (by customer I mean duely authorised
personnel who are employed by the organisation that commissioned the work)
has value.

--
Anthony Jones - MVP ASP/ASP.NET
Aug 8 '08 #20
re:
!I hadn't considered that by security you were
!referring to protecting your source code as an asset.

Yes, I was.

re:
!Still there are times when source isn't particularly valueable as an asset

Yes, there are such times.

For application developers who deploy their apps to their client's servers,
though, ( and there's tons of those ), it's far better for them not to deploy
raw code to the App_Code directory.

Otherwise, they're just giving their knowledge away to cut-and-paste ops.


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/
======================================
"Anthony Jones" <An*@yadayadayada.comwrote in message news:%2******************@TK2MSFTNGP04.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
>re:
!>>App_Code is no less secure than the bin directory
!>I'll take a strong exception to that...
!Why? Do you think it isn't true?

Anthony, you're rationalizing insecure procedures.

Name me *one* programmer who prefers to place raw source code
a server...and I'll show you a severely complacent person who's likely
to get the jolt of his life when his precious code is lifted.

re:
!>>I don't put any of my code there myself
!>Why ?
!I just don't ;)

So, you *do* agree with me.

re:
!Besides a two-bit programmer can still manage to compile a dll and drop
it in the bin
>>
Where the code will be a lot safer than if uploaded raw.
I think we're talking at cross purposes. I hadn't considered that by
security you were refering to protecting your source code as an asset. I
was thinking of security in terms of a black hat doing something malicious
to site. If such a person has access to the App_Code they have access to
the bin and in fact the whole site.

Still there are times when source isn't particularly valueable as an asset
and its accessibility to customers (by customer I mean duely authorised
personnel who are employed by the organisation that commissioned the work)
has value.

--
Anthony Jones - MVP ASP/ASP.NET


Aug 8 '08 #21

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

Similar topics

1
by: Bill Reynen | last post by:
Hello, Working in ASP.NET. I want to create several projects on the web server /Online /Online/App1 /Online/App2 /Online/App3
5
by: z. f. | last post by:
Hi, I'm working on a web project and i create classes to do business logic and connect to DB. i also need a windows application to do the same functionality as defined in classes inside the...
1
by: VB Programmer | last post by:
What is the best way to clone a project to a BRAND NEW PROJECT on my dev machine? Copy Project doesn't seem to work well. Example: I have a ShoppingCart template VS.NET solution. I want to...
8
by: vinesh | last post by:
I have sample Asp.Net Web Application project. Let me know how to keep the files related to this project (like the webform.aspx, WebForm1.aspx.vb, WebForm1.aspx.resx) in a separate folder within a...
0
by: SammyBar | last post by:
Hi all, My problem is basic. I'm starting to try web services with Visual Studio .NET 2002, .NET Framework 1.0. I'm testing the following configuration for my project. It's a ASP.NET Web Service...
9
by: jojobar | last post by:
In vs.net 2005 you can build the entire website, entire solution or a single page. The project I am working on has more than 1000 pages spread over 50-60 directories. We work on one or two of the...
49
by: Martin Unsal | last post by:
I'm using Python for what is becoming a sizeable project and I'm already running into problems organizing code and importing packages. I feel like the Python package system, in particular the...
0
by: ping235 | last post by:
Recently, i am busying myself on a project that support both the Full ..NET Framework 2.0 and .NET Compact Framework 2.0, with the same set of c# code, but have different project properties and...
3
by: skneife | last post by:
it seems that it is not possible to make a project Reference from a project class library to a website in the same solution, because the website doesn't contains any assembly (dll). So, if in the...
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
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: 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.