Saturday, January 16, 2010

Displaying External HTML file content in Microsoft MVC

 

We are developing an application where one of our MVC views is simply to render HTML snippets from an external file.  Since our favorite internet search engine did not turn up any information on how to do this, I am posting the following information. 

In our case the external HTML is a fairly simple snippet without javascript or form tags, so no manipulation of the file contents is required before display.

You can quickly read in the entire file to a string as follows:

using System.IO;

public static string GetHTMLContents(string filename)
{
string results = string.Empty;
if (File.Exists(filename))
{
results = File.ReadAllText(filename);
}
return results;
}


Then just place that string in the ViewData with a command like



ViewData["HTMLContent"] =  results;



and in the View render it with code that looks like:



<span style=" text-decoration:underline">HTML Content:</span><br/>
<%= ViewData["HTMLContent"] %>



Hope that helps.



Joe Kunk

Microsoft MVP


Okemos, MI USA


January 16, 2010

Sunday, January 03, 2010

What's New in Visual Basic 2010

 

This list is a subset of the documentation available from Microsoft on their MSDN site, provided as a learning resource. Click here to see the full page. 

Quiz yourself to see which features you fully understand.  Click the topic to see an explanation of the topic.  Note that this list is based on a unreleased version of the software and is subject to change in later releases.  Please provide updates via the comments section below.

 

Visual Basic Compiler and Language

Integrated Development Environment

 

New Visual Basic Language Samples

 

Hope that helps.

Joe Kunk
Microsoft MVP
Okemos MI USA
January 3, 2010

I like big lists and I cannot lie

 

To paraphrase the song “Baby Got Back”* by Sir Mix-A-Lot, I like big lists and I cannot lie.  (My apologies to the artist)

What I mean to say is that as the Microsoft developer space gains more capabilities and inevitably becomes more complex, it is harder for me to keep up with it all.  Long articles that explain everything step by step are wonderful, but I find it very beneficial to distill segments of these technologies down to a simple lists whenever possible and explore the individual elements in greater detail when needed. These lists give me a way to track what I already know and what I need yet to learn.

This year, I am determined to add WPF, WCF, MEF, MVC and Silverlight to the list of Microsoft .Net technologies that I can comfortably and effectively write software in.  That will involve writing lots of lists.  I look forward to sharing these lists with you on my blog.


Joe Kunk
Microsoft MVP Visual Basic
Okemos, MI USA
January 3, 2010

 

* A great song.  I was listening to it as I wrote this post.  Please support this artist and others by purchasing your music through legitimate sources that pay artist royalties.

Saturday, January 02, 2010

2010 Microsoft Most Valuable Professional in Visual Basic

I am very pleased to announce that I have been named a Microsoft MVP in Visual Basic for 2010! This is the second consecutive year that I have been the recipient of this honor.  I can hardly believe it!

I want to sincerely thank everyone that contributed to the decision to honor me with this award. 

At Microsoft I would like to specially thank PJ Forgione (MVP lead), Lisa Feigenbaum (Program Manager for Visual Studio languages), and Dustin Campbell (Visual Basic IDE Program Manager).

Locally I must thank Jeff Blankenburg, Jennifer Marsman, and Brian Prince, the best team of Microsoft Developer Evangelists that one could ever hope to work with.

I am truly humbled to be a Microsoft MVP when I consider the level of professionalism, knowledge, and community contributions represented by the Microsoft MVP community. 

Joe Kunk
Microsoft MVP
Okemos, MI USA
January 1, 2010