HtmlTemplateBase<> For the RazorEngine on CodePlex

The RazorEngine project on CodePlex is a powerful Templating library that utilizes the Razor Syntax. If you are trying to use this library and wondering where is the HtmlTemplateBase<> as it is shown on the project's page, it does not really exist! That code snippet on RazorEngine's home page is an example of what you could possibly do with that library.

There is a thread on the project's discussion board where this is being discussed. Apparently no one had time to put it together.

So I wrote a version of my own HtmlTemplateBase<> that supports the Html Helper and ViewBag. You should be able to add Ajax Helper if you need it. I won't go into much details, as the code should be self explanatory. I am not saying this is the best way to do it, but it works.

HtmlTemplateBase<>

Using the HtmlTemplateBase<>

Make sure this class is part of your Web/MVC Project. It will work in the context of a WebPages (MVC) only, unless you tweak it a little to work on WebForms. It's fairly simple to use this as the Template base class. Before parsing any Template, use this single line of code:

Notes

  1. This will add support for Html.EditorFor<>(), Html.EditorForModel<>() etc. within your Template.
  2. The Html Helper in your template will use the Model and Model Type that you use for the Template, not the Model Type of the Webpage it is being parsed in. Of course they can be the same. Much like the Html.Partial() helper method.
  3. The ViewBag will have all items added at the Page level prior to parsing the Template. You can set ViewBag items within your Template and they will be available at the Page level once you parse/execute the Template. However, if you set an item using ViewData["..."] = Value within your Template, it will not be available with ViewBag.ItemKey, within your Template, or outside the Template.

Hopefully this code will be enough to get you started on this.

Posted on September 29, 2011 03:33 by Haider

Where is Bing Maps Heading?

Bing Maps API has a  Control (Javascript Plugin, not to be confused with .Net or ActiveX Controls) that you can embed in Websites. About a year ago they released version 7.x of this api/control which supposedly is upto 300% faster than the previous version, and way cooler.

So for a recent project that uses Maps, I decided to look into the new version. After working with it for a couple of days, I realized that it is practically useless! First, many of the features have disappeared. Some of these features were the main reasons to choose Bing Maps over Google Maps. In addition, that illusive 300% increase in speed, I couldn't see it! Maps appear to load slower than before.

But thats not it, now you have to register each of your Website/Domain and get a Key to make the Maps work. If you didn't know, Google Maps DOES NOT require an API Key with its latest version. While Microsoft is trying to be like Google in this aspect, Google has already moved on from it.

Meanwhile, the Google Maps API version 3.x starting to look much nicer, loading fast, not requiring an API key, and enough flexible in terms of programmability.

Whoever is responsible for the changes in Bing Maps API, did not make smart decisions. I say that not just as my opinion. I have looked around and found enough discussions on these topics to know this is the general feeling of the developers.

So after wasting two days of work, I am back with the older version of the API, and if I am to upgrade to anything in the future, it will most likely be Google Maps.

May be someone will take note, and change the directions?

Knowing Microsoft, I don't think so.

Posted on September 23, 2011 03:52 by Haider

Canada's Dojo Directoy: www.dojos.ca

There is this Website recently launched as a part of dojolocator.com's global initiative. It is intended to be the Dojo Directory for Canada. The Website address is www.dojos.ca

The .ca authority allows second level domains, unline the .uk authority, therefore it was possible to acquire dojos.ca, short and sweet!

This Website currently features about 1,600 Martial Arts Schools, and provides Martial Arts Style Statistics in various Cities and Provinces of Canada.

The Website is built with ASP.NET 4.0 and C#. It uses SQL Server 2008 R2 for database. The site is hosted on a 64bit Windows 2008 Web server.

Martial Arts School owners in Canada can list their schools with dojos.ca, absolute free of cost. The dojolocator.com network attracts well over 100,000 visitors every month, and serves as a valuable resource to the Martial Arts community.

Posted on September 13, 2011 06:08 by Haider

ASP.NET RAZOR Hosting in Bangladesh

The new RAZOR view engine available along with ASP.NET MVC3 marks the beginning of a new era of ASP.NET. A decade ago, ASP.NET 1.0 was released along with .Net framework 1.0, and for over 10 years, ASP.NET Web Forms (Now being called as Web Forms View Engine) was the only option for Web Development with ASP.NET. While the RAZOR view engine on the surface may look like just a simpler and easier set of syntax for dynamic pages, it actually makes fundamental changes to how web development has been with Web Forms so far.

If you are located in Bangladesh and developing with the RAZOR view engine and MVC 3 framework, you are going to need a reliable Web Host offering these features, preferably on Windows Server 2008 and IIS 7.x (not Windows Server 2003 and IIS 6.x). Take a look at Alpha Net's offerings of ASP.NET hosting in Bangladesh. Alpha Net has been offering Windows based hosting in Bangladesh since 2001, and their infrastructure is constantly upgraded to keep up with the latest in technology. Their ASP.NET hosting is on a 64bit Windows 2008 R2 platform along with SQL 2008 R2 64bit Databases. Another unique feature is that they give you a VPN tool to securely connect to the database server and work as if it is on your local development machine. They also offer Windows VPS in Bangladesh.

This is Alpha Net's 10th year in service and innovation. They are running some interesting promotions to celebrate their 10th year in business. Contact them to find out more.

Hope it helps.

Posted on August 24, 2011 05:56 by Haider

dojolocator.co.uk - UK's Top Dojo Directory

Developed with ASP.NET 4.0 and backed by SQL Server 2008 R2, dojolocator.co.uk is a Dojo Directory for UK featuring obout 1,200 Martial Arts Schools in the United Kingdom. The Website also features pages for most Cities in the UK with an Interactive Map showing Dojo Locations in and around those Cities. A list of all Martial Arts Schools are also shown, as well as a chart showing Martial Arts Styles offered most in those area.

dojolocator.co.uk also allows ratings and reviews for schools. Ratings are based on instruction quality, other aspects and overall quality of a school. There is a rating widget that Member schools may show on their Websites.

Many schools also have programs, class schedule and style information available.

School owners, instructors, administrators or even students are allowed to maintain and update a school's information. There is no cost!

dojolocator.co.uk  also provides an overview of Martial Arts in UK.

The Website runs on a Windows 2008 Web edition server. It uses Linq2SQL for ORM, and JQuery on the client side.

Posted on June 22, 2011 03:59 by Haider