Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Is there any way to add a C# Web Form to an ASP.NET 4.0 Web Application that is written in VB.NET? I had an ASP.NET 2.0 *WEB SITE* that I recently converted to an ASP.NET 4.0 *WEB APPLICATION*. It was mostly written in VB.NET with a couple pages that had C# code behinds.

I've read the following article (the end section about multiple languages):

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

But it does not seem to help for the following two reasons

1) When I converted my site to an application, it didn't seem to add an APP_CODE folder at all
2) I'm not looking to just write a simple class, I actually want to be able to add a WEB FORM with a C# code behind

When I try to add a new item and I select which type of item I want to add, I am only given to option to add a VISUAL BASIC web form.

I have a workaround right now. If I need a new web form with a C# code behind, I take one of my old C# web forms and just copy and paste the form and C# code behind into the project and then rename it and change the class name as well. Then i make my changes and do what I need to do. It seems to work, but I was just wondering if there was an easier way.

You might wonder why want to put C# forms in my VB app. I wrote my app in VB (not well versed in C# but I can read it). I have a programmer working for me that is much more efficient with C#. I don't really have the budget to spend weeks/months getting her up to speed with VB.
Posted
Updated 18-Feb-11 8:10am
v2

1 solution

There won't be an easier way. If you want the web form that is currently C# to have it's code behind compiled into the same assembly as the VB.Net app, then you'll just have to convert them.
 
Share this answer
 
Comments
citronsmurf 18-Feb-11 14:29pm    
That's what I was afraid of. Copying and pasting from an existing .cs web form (luckily I had one before I converted to an app from a site) seems to work so well, it's just kind of annoying. I'll probably end up just taking one of the C# web forms and making a blank copy to use as a template that I can copy any time one of my C# programmers needs to add a new page.


I know some people probably would lecture me about mixing languages in the same application, but sometimes when you can't find a good local programmer you really don't have a choice. I'm just surprised that if you *CAN* have C# web forms in a VB.NET web application (which doesn't seem to have any adverse effects in my live app) then you'd think Microsoft would give you the option to create one from scratch when adding a new item, just to make life easier.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900