Language in Page directive in VS 2005

R

rjack

I'm using VS 2005 Beta 2.

In VS 2003, the Page directive in an aspx page has Language and
CodeBehind attributes. You can have the language be different than the
code behind file language. For instance, you can have

Language="vb"
CodeBehind="classA.cs"

In VS 2005, the CodeBehind attribute seems to have been replaced with
the CodeFile attribute, although this is not documented in the beta
documentation. Therefore, it becomes

Language="vb"
CodeFile="classA.cs"

This causes a compile error:

"The language of the code file is inconsistent with the language of the
page."

According to the documentation for both VS 2003 and VS 2005, the
Language directive is supposed to be the language embedded in the aspx
page. Therefore, I should be able to have a Language that is different
from the CodeFile page in VS 2005.

Why do I get this error? Is there a way to have a language for the page
be different from the code file language?
 
S

Steven Cheng[MSFT]

Hi rjack,

Welcome to ASPNET newsgroup.
As for the programming Lanugage for ASP.NET 2.0 page,'s aspx file and
codebehind file, here are some of my understanding:

Yes, as you've found for the current asp.net 2.0 page model, we are forced
to use the same programming language for aspx page and codebehind class.
This is because in asp.net 2.0, we 're using the partial class for asp.net
page. The .aspx file and codebehind File are of the same class, so that
they're compiled into the same class at dynamic compilation. So the class
declaration in codebehind file is

public partial class mdpage : System.Web.UI.Page


btw, in asp.net 1.x ,the code behind class and aspx page is compiled into
different class, they're parent/child class relation (aspx generated class
derived from the codebehind class). that's why they can use different
language to program while it is not allowed in the 2.0 model.

In fact, the 2.0's partial class model has bring much more good features
than the old one, for example, we don't need to explicitly declare member
field for control instances in codebeind file....

Here are the msdn reference which demonstrate the page compilation model
change from beta1 to beta2:

#Changes for Beta 2
http://msdn.microsoft.com/asp.net/beta2/beta2update.aspx

You can also find some other article on asp.net 2.0 's beta feature
change/postpone or beta2 to RTM changes.

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)







--------------------
| From: (e-mail address removed)
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Subject: Language in Page directive in VS 2005
| Date: 29 Sep 2005 13:07:26 -0700
| Organization: http://groups.google.com
| Lines: 29
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 68.81.183.207
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1128024452 10674 127.0.0.1 (29 Sep 2005
20:07:32 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Thu, 29 Sep 2005 20:07:32 +0000 (UTC)
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
.NET CLR 1.0.3705; .NET CLR 1.1.4322; Alexa Toolbar; .NET CLR
2.0.50215),gzip(gfe),gzip(gfe)
| Complaints-To: (e-mail address removed)
| Injection-Info: f14g2000cwb.googlegroups.com; posting-host=68.81.183.207;
| posting-account=egBesgwAAADr2AGpmzETviTrt74lbz3H
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!f1
4g2000cwb.googlegroups.com!not-for-mail
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:128088
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I'm using VS 2005 Beta 2.
|
| In VS 2003, the Page directive in an aspx page has Language and
| CodeBehind attributes. You can have the language be different than the
| code behind file language. For instance, you can have
|
| Language="vb"
| CodeBehind="classA.cs"
|
| In VS 2005, the CodeBehind attribute seems to have been replaced with
| the CodeFile attribute, although this is not documented in the beta
| documentation. Therefore, it becomes
|
| Language="vb"
| CodeFile="classA.cs"
|
| This causes a compile error:
|
| "The language of the code file is inconsistent with the language of the
| page."
|
| According to the documentation for both VS 2003 and VS 2005, the
| Language directive is supposed to be the language embedded in the aspx
| page. Therefore, I should be able to have a Language that is different
| from the CodeFile page in VS 2005.
|
| Why do I get this error? Is there a way to have a language for the page
| be different from the code file language?
|
|
 
S

Steven Cheng[MSFT]

Hi rjack,

How are you doing on this issue and does the information in my last reply
helps a littile? If there're anything else we can help, please feel free to
post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
--------------------
| X-Tomcat-ID: 83793527
| References: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Fri, 30 Sep 2005 05:43:51 GMT
| Subject: RE: Language in Page directive in VS 2005
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Lines: 101
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:128172
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi rjack,
|
| Welcome to ASPNET newsgroup.
| As for the programming Lanugage for ASP.NET 2.0 page,'s aspx file and
| codebehind file, here are some of my understanding:
|
| Yes, as you've found for the current asp.net 2.0 page model, we are
forced
| to use the same programming language for aspx page and codebehind class.
| This is because in asp.net 2.0, we 're using the partial class for
asp.net
| page. The .aspx file and codebehind File are of the same class, so that
| they're compiled into the same class at dynamic compilation. So the class
| declaration in codebehind file is
|
| public partial class mdpage : System.Web.UI.Page
|
|
| btw, in asp.net 1.x ,the code behind class and aspx page is compiled into
| different class, they're parent/child class relation (aspx generated
class
| derived from the codebehind class). that's why they can use different
| language to program while it is not allowed in the 2.0 model.
|
| In fact, the 2.0's partial class model has bring much more good features
| than the old one, for example, we don't need to explicitly declare member
| field for control instances in codebeind file....
|
| Here are the msdn reference which demonstrate the page compilation model
| change from beta1 to beta2:
|
| #Changes for Beta 2
| http://msdn.microsoft.com/asp.net/beta2/beta2update.aspx
|
| You can also find some other article on asp.net 2.0 's beta feature
| change/postpone or beta2 to RTM changes.
|
| Hope helps. Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
|
|
|
|
| --------------------
| | From: (e-mail address removed)
| | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | Subject: Language in Page directive in VS 2005
| | Date: 29 Sep 2005 13:07:26 -0700
| | Organization: http://groups.google.com
| | Lines: 29
| | Message-ID: <[email protected]>
| | NNTP-Posting-Host: 68.81.183.207
| | Mime-Version: 1.0
| | Content-Type: text/plain; charset="iso-8859-1"
| | X-Trace: posting.google.com 1128024452 10674 127.0.0.1 (29 Sep 2005
| 20:07:32 GMT)
| | X-Complaints-To: (e-mail address removed)
| | NNTP-Posting-Date: Thu, 29 Sep 2005 20:07:32 +0000 (UTC)
| | User-Agent: G2/0.2
| | X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1;
| .NET CLR 1.0.3705; .NET CLR 1.1.4322; Alexa Toolbar; .NET CLR
| 2.0.50215),gzip(gfe),gzip(gfe)
| | Complaints-To: (e-mail address removed)
| | Injection-Info: f14g2000cwb.googlegroups.com;
posting-host=68.81.183.207;
| | posting-account=egBesgwAAADr2AGpmzETviTrt74lbz3H
| | Path:
|
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli
|
ne.de!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!f1
| 4g2000cwb.googlegroups.com!not-for-mail
| | Xref: TK2MSFTNGXA01.phx.gbl
| microsoft.public.dotnet.framework.aspnet:128088
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | I'm using VS 2005 Beta 2.
| |
| | In VS 2003, the Page directive in an aspx page has Language and
| | CodeBehind attributes. You can have the language be different than the
| | code behind file language. For instance, you can have
| |
| | Language="vb"
| | CodeBehind="classA.cs"
| |
| | In VS 2005, the CodeBehind attribute seems to have been replaced with
| | the CodeFile attribute, although this is not documented in the beta
| | documentation. Therefore, it becomes
| |
| | Language="vb"
| | CodeFile="classA.cs"
| |
| | This causes a compile error:
| |
| | "The language of the code file is inconsistent with the language of the
| | page."
| |
| | According to the documentation for both VS 2003 and VS 2005, the
| | Language directive is supposed to be the language embedded in the aspx
| | page. Therefore, I should be able to have a Language that is different
| | from the CodeFile page in VS 2005.
| |
| | Why do I get this error? Is there a way to have a language for the page
| | be different from the code file language?
| |
| |
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top