By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,285 Members | 2,147 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,285 IT Pros & Developers. It's quick & easy.

Language in Page directive in VS 2005

P: n/a
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?

Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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/be...ta2update.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: rj***@elegancetech.com
| 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: <11**********************@f14g2000cwb.googlegroups .com>
| 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: gr**********@google.com
| 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: gr**********@google.com
| Injection-Info: f14g2000cwb.googlegroups.com; posting-host=68.81.183.207;
| posting-account=egBesgwAAADr2AGpmzETviTrt74lbz3H
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.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?
|
|

Nov 19 '05 #2

P: n/a
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: <11**********************@f14g2000cwb.googlegroups .com>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: st*****@online.microsoft.com (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: <ue*************@TK2MSFTNGXA01.phx.gbl>
| 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/be...ta2update.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: rj***@elegancetech.com
| | 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: <11**********************@f14g2000cwb.googlegroups .com>
| | 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: gr**********@google.com
| | 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: gr**********@google.com
| | Injection-Info: f14g2000cwb.googlegroups.com;
posting-host=68.81.183.207;
| | posting-account=egBesgwAAADr2AGpmzETviTrt74lbz3H
| | Path:
|
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.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?
| |
| |
|
|

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.