This week in tweets (01-02-2010)

Hardware and Software to look forward to in 2010

Hardware:
1. Google phone
2. Apple Tablet
3. Microsoft Tablet
4. Google Tablet
5. New iPhone
6. Microsoft phone?

Software:
1. Microsoft Windows Mobile 7
2. Apple Maps – They bought a mapping company mid last year (to replace Google Maps on iPhone?)
3. Google Chrome OS
4. Google Voice with VOIP (Google phone with data plan only?)
5. Exchange 2010
6. Office 2010 with Web Apps
7. Visual Studio 2010
8. Limited news on Windows 8

The battle between Apple, Google and Microsoft is just heating up.

Server side conversion of UserControl to html

In order to get the html out of an ASP.NET control you can use the following code:

string pathToUserControl = "~/Controls/MyUserControl.ascx";
    
System.Web.UI.Page page = new System.Web.UI.Page();
System.Web.UI.UserControl control = page.LoadControl(pathToUserControl);
page.Controls.Add(control);
    
StringWriter writer = new StringWriter();
HttpContext.Current.Server.Execute(page, writer, false);
    
string renderedHtml = writer.ToString();

This method is mostly used to send the html back to the client browser using web services.

Strongly typed view in ASP.NET MVC

When passing the model to MVC you have a couple of options.

Option 1: Passing un-typed model to the view

public ActionResult Product(string id)
{
    var product = new Product();
    product.ID = id;
    product.Name = "iPhone";
    ViewData["product"] = product;
}

In your view you have to cast the value in ViewData to the correct type as follows:

<%
    var item = (Product)ViewData["product"];
%>
<div>
    ID: <%= item.ID %>
    Name: <%= item.Name %>
</div>

Option 2: Pass a strongly typed model to the view

// ViewData["product"] = product;
ViewData.Model = product;

The Page directive of your view must specify the type it expects as follows:

<%@ Page Title="blah" ... Inherits="System.Web.Mvc.ViewPage<Product>" %>

Sometimes you may need to pass more than one object to the view. You can handle this by creating a new class that encapsulates all objects you need and pass an instance of that class to the view instead.

Icon Finder

Very cool website that allows you to find icons

IconFinder.net

The site uses AJAX and has icons of varying shapes and sizes. Check it out.