Blog moved to Iserialized.com



Note: My blog has been moved to www.iserialized.com
Please update your link!


Thursday, December 17, 2009

Adding C# and ASP.Net to Blogger (Part 2)

In one of my earlier posts I recommended using Windows Live Writer and the "Paste from Visual Studio" plugin to add code to your blog. But two days of struggling with layout I gave up, and stumbled upon the C# code formatter which is very easy to use!

To add C#, VB, ASP.Net etc, just following these steps:
  1. Copy the code segment you want to add
  2. Paste it into the source code text box
  3. Select language (C#, VB etc)
  4. Include line numbers, alternating background and embed stylesheet
  5. Press Format my code
  6. Copy the full content generated
  7. Paste it into the html view in Blogger
  8. Cut the whole style segment and paste it at the top of your blog. Yes I know, strictly speaking it should be included in the header part, but frankly i don't care(!)
  9. If you want to add another code segment to the same post, you don't need to embed the stylesheet this time as it is already there.
  10. To get rid of the extra empty line which is automatically added above your code segment, just remove the "code formatted by...." comment.
So do I still use Windows Live Writer? Nope!
The C# code formatter is enough for me, the editor in Blogger has some limitations, but Windows Live Writer  had allot of problems formatting my post correctly, especially when using the "Paste from Visual Studio" plugin. I started getting allot of paragraphs which destroyed the format, and I was also unable to get rid of the large gaps under the code segments, and yes, I did import my Blogger settings to Windows Live Writer without much improvements!

Here you can see how the pasted source code is formatted.

1 comment:

Blog moved to iserialized.com



Note: My blog has been moved to www.iserialized.com
Please update your link!


 
Blogglisten