Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 1st, 2006, 01:06 PM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Blog Controls in a C# Project

Maybe I'm stupid but how do I use the Blog controls in my C# site? I see how easy it would be in a VB site... Is there a C# version of the code anywhere?

Thanks much...

Mike H

 
Old May 1st, 2006, 03:12 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Mike,

You could use them in a C# web site as well. In the new project model, you can mix pages and controls with different languages.

Alternatively, you can translate the VB code to C# using an on-line converter like this one: http://www.dotnettaxi.com/Tools/Converter.aspx

It doesn't convert everything, but usually the converted code is a nice start. I can help you with the conversion if you have any problems. It would be nice to have a C# version of the Blog (and other applications in the book) but right now I just don't have the time to fully convert them.

If you want to give it it a try, let me know and I'll try to help as much as I can....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old May 1st, 2006, 04:44 PM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

    Thanks for the converter link. I actually started to manually convert it and then decided against it. Right now it works fine as a link to another page but I do still want it to "blend" into my web site so I would like to use the controls directly.
    I will try to get these to work in my project, I just noticed that when I did it initially it came up with errors with both .vb and .cs files in the same project. I guess I need to look into the proper way to do that.

Thank You

Mike H

 
Old May 2nd, 2006, 12:22 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Mike,

In a normal site you should be able to mix the two. Personally, I wouldn't recommend it, because you'll end up with a site that becomes harder to maintain.

However, technically it's possible. You can have a VB page that consumes a C# control, or the other way around.

Once you use the new ASP.NET Projects model, or the new deployment tool, things become different. Those tools compile the code behind for many files (either the entire site or a single folder) to a single assembly. That makes it impossible to mix the two languages, because the compiler can only handle a single language.
That's also the reason why you cannot have both .vb and .cs files in the App_Code folder.

Making any progress with the C# version?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old May 5th, 2006, 03:41 PM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use VB.Net and/or C# controls/classes in a C# website and vice versa. Here's how to it.

In the web.config file add the following:

<system.web>
   <compilation debug="true">
      <codeSubdirectories>
         <add directoryName="CS">
         <add directoryName="VB">
      </codeSubdirectories>
   </compilation>
</system.web>

Now, under the App_Code Asp.net Folder create two folders, name one as CS and the other VB. To create a folder under the App_Code Asp.net folder, right click the App_Code folder and choose New Folder. Name the folder accordingly.

Now make sure to add/create ALL ".cs" files to the CS folder and All the ".vb" files to the VB folder.

Once this is done, you can call any of your from a VB.Net or C# web page.

Note: Make sure to name your classes uniquely.

Happy programming.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrox Blog in C# madAlan BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 22 June 12th, 2011 04:09 AM
Wrox Blog: Viewing individual blog entries Tawanda BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 7 May 7th, 2007 12:06 PM
Blog project in Asp.net 2.0 instant results sriniblog ASP.NET 1.0 and 1.1 Basics 0 December 14th, 2006 05:44 PM
Controls New Class Library project page 60??? Ghistos BOOK: ASP.NET Website Programming Problem-Design-Solution 5 July 27th, 2004 10:40 PM
Using Multimedia controls in ADO.NET project Vishal The Great One ADO.NET 0 July 23rd, 2003 04:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.