Any reason one page's code behind shouldn't be vb an another C#

  • Thread starter Thread starter AAaron123
  • Start date Start date
A

AAaron123

I was advised once not to mix C# and VB in the same project (I think
"project" was the word used. Maybe it was "solution").

So I added two projects to my solution - a vb library and a c# library.

I've since learned that there is a "Web Site" and a "Web Application
Project" configuration and wonder if the advice applies to a "Web Site".

So the question is: For a Web Site, is there any reason one page's code
behind shouldn't be vb an another C#.

As far as I can tell it works OK since I had it that way once without an
apparent problem.

Thanks
 
I was advised once not to mix C# and VB in the same project (I think
"project" was the word used. Maybe it was "solution").

So I added two projects to my solution - a vb library and a c# library.

I've since learned that there is a "Web Site" and a "Web Application
Project" configuration and wonder if the advice applies to a "Web Site".

So the question is: For a Web Site, is there any reason one page's code
behind shouldn't be vb an another C#.

As far as I can tell it works OK since I had it that way once without an
apparent problem.

Thanks

ASP.NET will tolerate mixed languages between pages and even between
master and content pages. It will not allow mixed languages though for
class files in the App_Code directory. The criteria is the compilation
process. Where source files have to be compiled together they must be
a single language, but when they are compiled as separate modules then
it doesn't matter because they all translate to the same intermediate
form (MIL).
 
re:
!> It will not allow mixed languages though for class files in the App_Code directory

That is totally untrue.

You can add subdirectories to the App_Code directory
in order to process multiple languages under the App_Code directory.

In order to do this, you need to register each subdirectory in the application's Web.config.

<configuration>
<system.web>
<compilation debug="false">
<codeSubDirectories>
<add directoryName="VB"/>
<add directoryName="CS"/>
</codeSubDirectories>
</compilation>
</system.web>
</configuration>

Then, simply creating the App_Code\VB and App_Code\CS directories,
and placing your VB and CS files in each, will allow you to use both languages in your app.

This only works in ASP.NET 2.0 or later.




Juan T. Llibre, asp.net MVP
¿ Estas probando VS 2010 y ASP.NET 4.0 ?
Regístrate (gratis) en los Foros de VS 2010 y ASP.NET 4.0, en español
http://asp.net.do/foros/forums/
=====================================================
 
AAaron123 said:
I was advised once not to mix C# and VB in the same project (I think
"project" was the word used. Maybe it was "solution").

So I added two projects to my solution - a vb library and a c#
library.

I've since learned that there is a "Web Site" and a "Web Application
Project" configuration and wonder if the advice applies to a "Web
Site".

So the question is: For a Web Site, is there any reason one page's
code behind shouldn't be vb an another C#.

As far as I can tell it works OK since I had it that way once without
an apparent problem.

Thanks

Four great replies so quick.

Thanks
 
Back
Top