citronsmurf
asked on
Adding C# Web Form to VB Web Application
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 mulitple 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
I've read the following article (the end section about mulitple 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
ASKER
There are no App_code folders for an asp.net web application. That's for web sites
Note: For Asp.net web app right click on your web app, click add, then new folder then name the new folder App_Code (see attached picture)
You have to add this yourself. VS2010 will not do it for you when you created the web app. Once created add any web form or C# classes files.
Note: If you cannot create it your project may not be setup properly, just in case: what kind of web app project is it?
Asp.net web app, Asp.net mvc2 web app.
You have to add this yourself. VS2010 will not do it for you when you created the web app. Once created add any web form or C# classes files.
Note: If you cannot create it your project may not be setup properly, just in case: what kind of web app project is it?
Asp.net web app, Asp.net mvc2 web app.
ASKER
How will this help me create new web forms with a C# codebehind file?
mas_oz2003, you should not create an App_Code folder in a web application project. This is because ASP.NET will ALWAYS compile all code in APP_CODE at runtime. It would get compiled twice, once into the web application's main assembly and then again into a seperate assembly. See http://vishaljoshi.blogspot.com/2009/07/appcode-folder-doesnt-work-with-web.html
You can convert the C# code to VB.NET with this tools:
http://codeconvert.codeplex.com/
http://msdn.microsoft.com/en-us/magazine/cc163652.aspx
http://www.codeproject.com/KB/macros/Code_convert_add-in.aspx?msg=3190160
And then you can add the VB.NET files to your web application.
http://codeconvert.codeplex.com/
http://msdn.microsoft.com/en-us/magazine/cc163652.aspx
http://www.codeproject.com/KB/macros/Code_convert_add-in.aspx?msg=3190160
And then you can add the VB.NET files to your web application.
one more thing u may need to add in your web config
<configuration>
<system.web>
<compilation>
<codeSubDirectories>
<add directoryName="VBCode"/>
<add directoryName="CSCode"/>
</codeSubDirectories>
</compilation>
</system.web>
</configuration>
Refer to
http://www.experts-exchang e.com/Prog ramming/La nguages/.N ET/ASP.NET /Q_2684657 9.html#a34 984528
codeSubDirectories Element for compilation
<configuration>
<system.web>
<compilation>
<codeSubDirectories>
<add directoryName="VBCode"/>
<add directoryName="CSCode"/>
</codeSubDirectories>
</compilation>
</system.web>
</configuration>
Refer to
http://www.experts-exchang
codeSubDirectories Element for compilation
anurag_onnet - that would make sense for a Web Project but the asker is building a Web Application. There should not create an App_Code folder in a web application project (see my comment above)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
then you can put the C# files there.