# Wednesday, 27 January 2010

From the Swiss MSDN blog:

In this 108 page hands-on lab you will learn how to use Beta 2 of Visual Studio 2010 and Beta 1 of Microsoft Silverlight 4 to create a data driven line of business style rich internet application that implements many of the new features that Silverlight 4 introduces. We will base our solution on the Windows Communication Foundation (WCF) RIA Services.

The solution will be an order-management system that shows a list of orders in a data grid and details of a selected order in a details pane. The system will validate user entries and have the capabilities of printing order reports and exporting order lists to Microsoft Excel.

Download the hands-on lab manual in PDF and Word format, the database and the final sample solution.

These features are implemented in the lab:

  • True multi-tier architecture.
  • Entity framework and service layer definition.
  • Data filtering, paging, sorting and grouping.
  • Data modification and validation.
  • Foreign key management.
  • Projections.
  • Programmatic printing from a Silverlight application.
  • COM interop with Microsoft Excel and running full-trust out-of-browser.

Silverlight4WCFRIAServicesHandsOnLab

Grz, Kris.

Wednesday, 27 January 2010 07:33:33 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, 13 January 2010

While taking a look at the new Ajax library Microsoft put online I noticed at the bottom of a certain page a link to an interesting whitepaper: Building high performance websites. It’s an interesting read by James Senior and Dan Wahlin.

These are the main topics being discussed:

The Microsoft Ajax Content Delivery Network (CDN)
Loading ASP.NET Ajax Scripts
Loading jQuery Scripts
The ASP.NET Ajax Library Script Loader
Using the ASP.NET Ajax Script LoaderLoading Custom
Script Combining 
Using the Script Loader when Debugging 
Using the Script Loader's Lazy Loading Feature to increase performance 
JavaScript Application Performance Tools 
The Download Time Optimizer (Doloto) 
Microsoft Ajax Minifier
Internet Explorer JavaScript Profiler 
Internet Information Server 7 Compression and Caching Options 

Grz, Kris.

Wednesday, 13 January 2010 07:17:25 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Saturday, 05 December 2009

Yesterda I went to Kinepolis in Brussels for what was going to be a great afternoon. Scott Guthrie doesn’t come every year to Belgium, actually it was its second time, so when he does you better be there to hear what he’s talking about.

The guys from Visug did a great job preparing the event and had prepared a little fun ingredient for Scott. Everybody got to wear red polo shirts:

belgium_thumb_65DCE55C

The session itself covered the following topics:

For me personally it was a great opportunity to see and talk with Scott again after the last MVP summit and there was some pretty interesting content about web related technologies (my favorite). Microsoft’s really doing a great job for webdevelopers with brining out new tools, new little additions to a more maturing web platform (ASP.NET 4.0), investing in new ways to let developers develop close to the raw metal with MVC and making it possible for them to create compelling applications with Silverlight.

One of the nice intros about Silverlight is its streaming capabilities with a cool pixar style animation: http://www.iis.net/media/experiencesmoothstreaming.

 

Grz, Kris.

Saturday, 05 December 2009 04:12:00 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [1]  | 
# Wednesday, 02 December 2009

With a lot of ajax, sometimes too much, being used in modern web applications it usually means that also calculations or data is being kept on the client. That’s all great but sometimes one has to perform a postback to the server. When the browser unloads and all form data’s passed to the server the javascript variables that were living happily in the browser are lost. A possible solution is to use a hidden field to send it back and forth. Some source code explains this scenario better:

Markup:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="passjsdataviahiddenfield.aspx.cs" Inherits="betslap.passjsdataviahiddenfield" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {
        
            $('#<%= btnGo.ClientID %>').click(function () {
                var txtValue = 'Hello ' + $('#<%= txtInput.ClientID %>').val();
                $('#<%= hidden1.ClientID %>').val(txtValue);
            });
        });
     
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:HiddenField runat="server" ID="hidden1" />
        Fill in your name please: <asp:TextBox runat="server" ID="txtInput" />
        <br />
        <asp:Button runat="server" ID="btnGo" Text="Go!" OnClick="btnGo_Click" />
        <br />
        <asp:Literal ID="Literal1" runat="server"></asp:Literal>
    </div>
    </form>
</body>
</html>

Codebehind:

using System;

namespace betslap
{
    public partial class passjsdataviahiddenfield : System.Web.UI.Page
    {
        protected void btnGo_Click(object sender, EventArgs e)
        {
            Literal1.Text = hidden1.Value;
        }
    }
}

In the markup I make use of the new CDN (Content Delivery Network) from Microsoft. In the piece of javascript that follows a click event is wired and to the button control. The value of the textbox prefixed with the string Hello is put in a local variable txtValue. Then that variable’s used to fill up the hidden field value attribute. Once the button gets clicked this value passing to the hidden field gets processed and then the postback occurs. There we set in the Click eventhandler, on the server, the text of the literal control to the text of the hidden field, in which we passed our javascript variable. The page gets processed, html is rendered and sent back to the browser. Both the value of the hidden field and the text of the literal are the same right now. This demonstrates the working.

Something else that I touched is this syntax:

<%= btnGo.ClientID %>

Since ASP.NET generates the ids of the html that gets rendered it can be sometimes something else than you expect. Especially when using master pages and javascript a lot of people get surprised with the, in their eyes, unpredictable behavior as it also generates a lot of prefixes. ASP.NET exposes the ClientID property on server controls which provides us with the rendered id on the client. With this line we inject that ClientID directly into the code of javascript, which gets rendered to the browser and there the correct id is always available.

To learn more about Microsoft CDN take a look at this page: http://www.asp.net/ajaxlibrary/CDN.ashx.

Grz, Kris.

ASP.NET | CDN | jQuery
Wednesday, 02 December 2009 20:46:59 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, 01 December 2009

Recently I got this book for a review. The book itself is ASP.NET 3.5 Content Management System Development by Packt publishing.

1847193617

The book’s right for the right kind of people: people who started with ASP.NET, played around with it and now want to learn more of some of the concepts of ASP.NET. This is definitely not a book for developers who’ve been doing some hardcore web development with ASP.NET themselves.

What I liked is the order in which the book’s written. All chapters follow nicely one after another and it shows in each chapter steps to either build on the former or how to refactor the previous code and for what reason.

Chapter 1: a quick and dirty file based CMS system with only one page gets created after how it’s shown how to set up and configuring IIS and ASP.NET.

Chapter 2 is a great refrehser, or introduction, of SQL statements and installing SQL Server Express 2005 as a database. What I really liked about this chapter’s something that mostly gets overseen: SQL injection. What its is and what .NET does to prevent it

Chapter 3 takes you through a basic multilayered architecture which will be implemented in the small, now database using, application. What I found a bit of a pity was the usage of typed datasets. In a world where one sees Microsoft moving more and more to Linq and Entity Framework this is a bit of a missed chance. On the other hand typed datasets is still used a lot in the industry. And as told before, this is a book for people having gone through beginner tutorials first. Also a good basis for further chapters is made with the new architecture which goes beyond a simple: here’s a page and some controls which connect directly to the database.

Chapter 4 introduces the reader to an important concept: security. How to configure sqlmembershipprovider, creating the database, making use of the aspnet_regsqltool, roles and making use of the login controls.

The next chapter shows how to create an articles module. An introduction to user controls, and making use of roles.

Chapter 6 leads the reader into the world of themes, master pages, skins and menus. First it’s shown how to add items directly with a wizard to the menu and then a more common approach’s used with sitemaps.

Chapter 7 is all about the fileupload control, working with files (image gallery) and creating RSS for your content management system. 

The fore last chapter’s more about finishing touches and adding reporting to the application, nice little additions. Also a couple of tips about SEO are highlighted (using the title and meta tags).

The last chapter goes into further possibilities: upgrading to a real full blown SQL Server edition, how to use base pages in the application and error handling.

 

What I liked about the book is the way the authors write, it’s technical content but with humor added on top. It’s a kind of book you’ll like to read when you want to get to know as an aspiring developer. The topic about SQL injection was a big plus for this book just to get people more aware about the problems that can arise with it.

Grz, Kris.

Tuesday, 01 December 2009 20:32:06 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, 30 November 2009

Microsoft’s investing in CDN for a lot of their ajax scripts and also jQuery, we already knew that for a while. Now they also added support for SSL so when you use your site with https it shouldn’t give an enduser the warning anymore about mixed content. The very well known “This page contains both secure and nonsecure items” message.

There’s a whole list available out there: http://www.asp.net/ajaxlibrary/cdn.ashx.

At first I didn’t see the dataservice.js scripts anymore, the ones that enable people to use ajax against ADO.NET Data Services, I mean WCF Data Services after the product got renamed, but they also got renamed to:

  • http://ajax.microsoft.com/ajax/beta/0911/MicrosoftAjaxAdoNet.debug.js
  • http://ajax.microsoft.com/ajax/beta/0911/MicrosoftAjaxAdoNet.js
  •  

    Besides the new CDN SSL feature there’s also a new Library available for Microsoft Ajax. Also quite a lot of new tutorials have been added for the new Ajax library.

    Grz, Kris.

    Ajax | CDN | Library | Links | Microsoft Ajax | SSL
    Monday, 30 November 2009 09:01:06 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
    # Saturday, 28 November 2009

    I got this question in one of the new forums over at ASP.NET. I took a bit of time to search and this is the result I came up with:

    Default:

    By default when you right click on the MDI document tab you get this context menu which will look familiar to most people from previous versions of Visual Studio.

    vs2010_mdi_01

    Solution:

    Use the menu and to go Tools, Customize

    vs2010_mdi_02

    Then from the new window select the second tab Commands. Check the radiobutton context menu and from the combobox choose Other Context Menus | Easy MDI Document Window:

    vs2010_mdi_03

    Click the Add Command… button and from the new window choose on the left Window and on the right Close all documents.

    vs2010_mdi_04

    Click on the OK and then on the Close button and you’re done. Nice and easy.

    Result:

    Your newly added context menu item for the MDI tab in all its glory:

    vs2010_mdi_05

    Grz, Kris.

    Saturday, 28 November 2009 15:46:26 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
    # Tuesday, 24 November 2009

    Sometimes you need to find out in which tables a certain column name exists. For example when you want to find out where it’s being used as a foreign key. Here’s a handy script to use in T-SQL.

    SELECT OBJECT_NAME(object_id), * FROM sys.columns WHERE name = 'columnname'
    This makes use of the OBJECT_NAME function in T-SQL which according to the documentation: Returns the database object name for schema-scoped objects.

    Grz, Kris.

    Tuesday, 24 November 2009 09:07:02 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [2]  | 
    # Thursday, 19 November 2009

    A lot of cool stuff's coming out soon and there are already beta bits available. With beta bits there are also already videos available to look at and get familiar with what will be available.

    Enjoy watching them.

    Grz, Kris.

    Thursday, 19 November 2009 17:23:00 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
    # Wednesday, 18 November 2009

    I found this question on the ASP.NET forums. The member asking this question already knew that the collections were Cookies, Form, Servervariables and Querystring but wanted to know the exact order. Well I got curious but instead of making a dedicated test project I opened up Reflector. Looking up the HttpRequest class’ indexer gave me this code:

    public string this[string key]
    {
        get
        {
            string str = this.QueryString[key];
            if (str != null)
            {
                return str;
            }
            str = this.Form[key];
            if (str != null)
            {
                return str;
            }
            HttpCookie cookie = this.Cookies[key];
            if (cookie != null)
            {
                return cookie.Value;
            }
            str = this.ServerVariables[key];
            if (str != null)
            {
                return str;
            }
            return null;
        }
    }

     

    It’s on the other hand always better to directly call the most specific collection directly. This avoids getting strange things in your code like expecting a key in the Form collection and getting the same key from the QueryString collection which could have a different, or none at all, value than what you expect. Fun debugging sessions follow after that…

    Grz, Kris.

    Wednesday, 18 November 2009 05:02:00 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |