MIX 2009 and ScottGu Goodness

MIX 2009 in Las Vegas is only three days away. There will be a lot of interesting announcements including the new .NET MVC Framework and more information on Silverlight 3.0, ASP.NET 4.0, Dynamic Data etc. You could find more about MIX 2009 here

Here is a video where ScottGu talks about MIX 2009 and what’s it’s like to speak in large audiences at MIX, PDC etc..


Get Microsoft Silverlight

Here are few Flickr pics of ScottGu’s from Las Vegas,

Scott smiles at the bear!

Scott in 70's suit

Masked man coding

Tatoo

What would ScottGu do?

What would ScottGu do?

ScottGu usually wears his red polo at the Mix, you could sign this petition started by Scott Hanselman here so he appears in red this year again

http://www.petitiononline.com/RedShirt/petition.html

.

BlackBerry Java Application Development using Visual Studio

Introduction

BlackBerry JDE or any other platform like NetBeans could be used for BlackBerry java application development. As a .NET developer I prefer using Visual Studio because of the features it provides over BlackBerry JDE and try to explain the same in this article

Background

I have been using BlackBerry JDE for a while now since I started BlackBerry development. After becoming familiarized with the 4.2.1 API that I am using, I decided to use Visual Studio because of its capabilities and find it very handy. I still use BlackBerry JDE for debugging & signing purposes when required.

Details

Here are the cons and pros before you decide if you want to use Visual Studio

Cons

  • Debugging
  • Signing
  • RIM BlackBerry API Intellisense
  • Error Navigation (Cannot navigate to the error line from output window but could navigate to the file)

Pros (over RIM JDE)

  • Better Syntax Highlighting, Code Outlining (CTRL + M, O – collapses everything)
  • Intellisense
  • Code Snippets (code snippet name – if, for & tab + tab)
  • Commenting & Uncommenting (CTRL + K, C)
  • Better Formatting (CTRL + K, D), Better Navigation(for functions & classes using the top dropdowns), Line Numbers – easier to read.
  • Source Gear Vault Integration
  • Better Search, Replace & Bookmarking capabilities(CTRL + K, K to bookmark, CTRL + K, N to move next etc.)
  • Get to use my customized Dark Theme( the best of it)
  • And all other features VS 2005 provides

I use VS 2005 as J# support is removed in VS 2008. Lets consider Hello World project, you could see this line in output window when you build the project in BlackBerry JDE.

  1. C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\bin\rapc.exe -quiet import="..\..\Program Files\Research In Motion\BlackBerry JDE 4.2.1\lib\net_rim_api.jar" codename=com_rim_helloworld com_rim_helloworld.rapc warnkey=0×52424200;0×52435200;0×52525400 C:\BBProjects\helloworld\HelloWorld.java C:\BBProjects\helloworld\img\helloworld_jde.png C:\BBProjects\helloworld\resource\HelloWorldRes.rrc C:\BBProjects\helloworld\resource\HelloWorldRes.rrh C:\BBProjects\helloworld\resource\HelloWorldRes_de.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_en.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_es.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_fr.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_it.rrc

If your project contains too many files, then the above line would be something like this

  1. C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\bin\rapc.exe -quiet import="..\..\Program Files\Research In Motion\BlackBerry JDE 4.2.1\lib\net_rim_api.jar" codename=com_rim_helloworld com_rim_helloworld.rapc warnkey=0×52424200;0×52435200;0×52525400 @com_rim_helloworld_build.files

@com_rim_helloworld_build.files contains all the files included in your project. RIM JDE will automatically create this for you when required

This is important to build in Visual Studio to check if there are any errors in code. Now lets open Visual Studio and create a new J# class library project(C# or J# project does not matter, as the file extension is what that matters)

Create the J# project in a different directory, delete the default class1 file, close VS and move the J# project contents to your existing blackberry project so that everything is in one place. Now open the project in VS and include the necessary files. This will look something like this at this point

Now that you have included the files, you can code in visual studio and would require to build project to check for the errors. Lets create a batch file to build java project from within the Visual Studio. Here is the code for building and showing if succeeded or not.

  1. "C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\bin\rapc.exe" -quiet import="..\..\Program Files\Research In Motion\BlackBerry JDE 4.2.1\lib\net_rim_api.jar" codename=com_rim_helloworld com_rim_helloworld.rapc warnkey=0×52424200;0×52435200;0×52525400 C:\BBProjects\helloworld\HelloWorld.java C:\BBProjects\helloworld\img\helloworld_jde.png C:\BBProjects\helloworld\resource\HelloWorldRes.rrc C:\BBProjects\helloworld\resource\HelloWorldRes.rrh C:\BBProjects\helloworld\resource\HelloWorldRes_de.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_en.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_es.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_fr.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_it.rrc
  2. @echo off
  3. if not exist "com_rim_helloworld.err" goto 20
  4. @ECHO "Build Failed."
  5. goto end
  6. :20
  7. @ECHO "Build Succeeded."
  8. del com_rim_helloworld.cod
  9. :end

Create a batch file using the above code in the project directory and add this into external tools to run within VS. You could do the same using MenuBar: Tools–>External Tools. Add one and setup the batch file, initial directory etc as shown below

You could set a keyboard shorcut like SHIFT + CTRL + F7 and execute it, you will see the results in output window.

Just change something in the code and build again(using shortcut or external tool), you will see the error details. You could then navigate to appropriate file from clicking in the output window

That’s it you are all set up for BlackBerry java application development in visual studio. I use both Visual Studio(for development) and BlackBerry JDE(for debugging & signing) to get the best of both worlds.

Also the BlackBerry build and signing process could be automated using BB Ant Tools if required.

Download

Download the J# Project with all the files here

Hope you find this article useful, happy coding and have fun!

Ponnu

SQL Server Event in Manchester

SQL Server user group beings 26th Feb in Manchester with Tony Rogerson talking on Bits and Bobs to help the developer and DBA with TSQL and Martin Bell on Table Valued Parameters in SQL Server 2008.

It’s nice to see SQL Server User Group forming in Manchester and organising the event. It’s been a while since the last Manchester .NET meeting, I have planned to attend. Here are the meeting details

Agenda

18:00 – 18:30 – Introduction, Networking and Food

18:30 – 19:00 – Round Table problems and answers, SQL nuggets – bring a tip or 1 – 5 minute demo and share with your peers.

19:00 – 19:45 – Bits and Bobs to help the Developer – TSQL, Tony Rogerson, SQL Server MVP
In this session I will look at a number of techniques and features in the product that help Developers and DBA’s allike create robust and scalable queries. We will look at how the optimiser can use the schema to help it, parameter sniffing, table valued functions, cte’s, table valued variables and a few more [once I've thought about them - please email me tonyrogerson@torver.net if there is anything specific].

19:45 – 20:00 – Break

20:00 – 21:00 – Table Valued Parameters – Saints or Sinners?, Martin Bell, SQL Server MVP
With the release of SQL Server 2008 and the new Table Valued Parameter feature, should we all be using them or are they the spawn of the devil? Martin will look at what options are available in the different versions of SQL Server and compares the performance and practicalities of using each one. 

Location:
Remarc,
3rd Floor,
Westminster House,
Minshull Street,
off Portland Street,
Manchester,
M1 3HU 

Register here

Update 1:

The Meeting has been postponded to later this month\early march due to bad weather.

Update 2:

Postponded to 26th Feb

Remote Desktop with Dual Monitors

I recently came across this, find it very useful and productive at work. If you are using dual monitors, could use the same when doing a Remote Desktop. To use Remote Desktop for dual monitors, type

mstsc /span

 

and run in the command prompt. There are few limitations in using this though, you can find them here in MSDN blog.

This works in Remote Desktop client V6.0 or higher which means having Vista is ok, Windows XP users might have to update their client. The RDP client could be updated from here

http://support.microsoft.com/kb/925876

 

I use a lot of saved RDP connections, in fact have a RDP folder in the Taskbar. If that’s the case, open the *.RDP file in notepad and add this line at the end

Span Monitors:i:1

 

And finally if you are using SplitView, it supports Remote Desktop with Dual Monitors which means it will take care of resizing windows within monitor and other features for you, otherwise you will have to resize windows manually.

Ponnu

BlackBerry JDE and source control Vault integration

I have been developing applications for Blackberry recently using Blackberry JDE in Java. I have always used Vault for source control in Visual Studio and it integrates well with Visual Studio. Here is how to do it in BlackBerry JDE.

BlackBerry JDE supports source control integration as you can see in this screenshot

BlackBerry JDE Source Control Preferences

The tricky bit is to setup the vault command in there. SourceGear Vault has a command line tool “Vault” which could be used. Here is the usage of it,

Vault Command Usage

Here is checkout command usage,

Vault Checkout Command Usage

Now enable source control integration and setup appropriate appropriate commands for checkout, revert and add file for source control in preferences dialog of BlackBerry JDE as shown below

BlackBerry JDE Source Control Preferences - Vault

Checkout Command:

vault checkout -host vault.yourcompanyname.com -user yourusername -password yourpassword -repository “Repository name” %1

Revert Command:

vault undocheckout -host vault.yourcompanyname.com -user yourusername -password yourpassword -repository “Repository name” %1

Add File Command:

vault add -host vault.yourcompanyname.com -user yourusername -password yourpassword -repository “Reporsity name” -commit repositoryfolderpath %1

 

After you setup these, make sure to setup vault command in path variable for your PC so the JDE picks it up. As for Vista, goto Computer –> Properties –> Advanced System Settings –> Environment Variables as show below,
Environment Variable Settings Vista

Vault Command Path:

C:\Program Files\SourceGear\Vault Client

 

That’s it, you are all set to go. The JDE with Vault will work fine now. The only problem I found is the inability to checkin files and to specify dynamic repository path in add script from within the JDE, will update the post once I find some info on that.

Ponnu

ASP.NET Charts – Storage Mode

Microsoft has released charts for ASP.NET few weeks back at the PDC. ScottGu has blogged about it here. I have been using charts in the past from a third party vendor and have converted them all to ASP.NET charts because of the variety & extensibility they provide and it will be part of .NET Framework 4.0 moving forward even though it’s a separate installation now . It was acquired from Dundas Charts by Microsoft.

One thing I could not find in the documentation is a way change the location where chart is stored. By default it’s stored in hard disk and the location is specified in the web.config file as below

  1. <appSettings>  
  2.     <add key=“ChartImageHandler” value=“storage=file;timeout=20;dir=c:\TempImageFiles\;”/>  
  3. </appSettings>  

 Many times, the chart image generated might differ from user to user. In those kind of scenarious it’s better to store the chart image in the memory.

  1. <appSettings>  
  2.     <add key=“ChartImageHandler” value=“storage=memory;timeout=20;dir=c:\TempImageFiles\;”/>
  3. </appSettings>  

And lastly the chart image could even be stored in session if required,

  1. <appSettings>  
  2.     <add key=“ChartImageHandler” value=“storage=session;timeout=20;dir=c:\TempImageFiles\;”/>
  3. </appSettings>  

But make sure you use “out of proc” mode for session for this to work.

Ponnu

A whole new year

I celebrated my birthday last week and would like to thank Phil, Tim & everyone else (colleagues, friends & family) for making it such a wonderful memorable day and for all their wishes & gifts. I did not expect something like that (see pics below) especially from my manager Phil and Tim, was totally surprised. We even went out for lunch, it was very nice of them to spend their time.

Last year was good, met lot of people, worked on lot of things in different roles, have learnt lot of things in general related to work, technology, people, culture… the list goes on…… and am thankful to all of them.

A new whole year, time to set/review goals and work towards it which would help me personally (in life) and also professionally (at work).

Here are few pics, will be adding more soon.

 

 

Ponnu

Silverlight 2 RTM Releasing Today

Microsoft has announced yesterday that Silverlight 2 will be releasing today. You can check the announcement here in Microsoft’s press release

Microsoft Releases Silverlight 2

Silverlight -plugin with a download size of only 4 MB provides rich support to video stream and works on most of the browsers in Mac, Windows & Linux.

You could listen to ScottGu’s teleconference here

ScottGu’s Teleconference

ScottGu shares information like how Silverlight was used by NBC for 2008 Olympic Games and statistics of the same. He also answers many questions like Silverlight’s support in Mobile, iPhone and Chrome etc..

Silverlight 2 includes the following features, 

.NET Framework support with a rich base class library. This is a compatible subset of the full .NET Framework.

Powerful built-in controls. These include DataGrid, ListBox, Slider, ScrollViewer, Calendar controls and more.

Advanced skinning and templating support. This makes it easy to customize the look and feel of an application.

Deep zoom. This enables unparalleled interactivity and navigation of ultrahigh resolution imagery.

Comprehensive networking support. Out-of-the-box support allows calling REST, WS*/SOAP, POX, RSS and standard HTTP services, enabling users to create applications that easily integrate with existing back-end systems.

Expanded .NET Framework language support. Unlike other runtimes, Silverlight 2 supports a variety of programming languages, including Visual Basic, C#, JavaScript, IronPython and IronRuby, making it easier for developers already familiar with one of these languages to repurpose their existing skill sets.

Advanced content protection. This now includes Silverlight DRM, powered by PlayReady, offering robust content protection for connected Silverlight experiences.

Improved server scalability and expanded advertiser support. This includes new streaming and progressive download capabilities, superior search engine optimization techniques, and next-generation in-stream advertising support.

Vibrant partner ecosystem. Visual Studio Industry Partners such as ComponentOne LLC, Infragistics Inc. and Telerik Inc. are providing products that further enhance developer capabilities when creating Silverlight applications using Visual Studio.

Cross-platform and cross-browser support. This includes support for Mac, Windows and Linux in Firefox, Safari and Windows Internet Explorer.

I will be blogging more about Silverlight in the coming days.

Ponnu

jQuery Cheat Sheet

Scott has created a nice cheat sheet that has all the functions related to jQuery in one page. You could download it from here and print it for quick reference. It’s very handy rather than going to JQuery help.

http://www.gscottolson.com/jquery/jQuery1.2.cheatsheet.v1.0.pdf

Sortable GridView using jQuery’s TableSorter

Introduction

This blog post explains how to use jQuery’s plugin Tablesorter to implement client side sorting in ASP.Net Gridview. This comes in handy especially when object data source is used with grid view as gridview does not provide sorting out of the box

Implementation

To implement TableSorter, the rendered table should have THEAD in the markup. Gridview does not provide this by default but we could achieve it either by setting appropriate properties or by using a CSS friendly control adapter. We will do it by using the former method.

Sample

You could have a look at it online here http://ponnu.net/TableSorter

Using the code

We should get the table with THEAD tags for the gridview to implement the sorting. So, lets do that

  1. protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (this.gvEmployees.Rows.Count > 0)
  4.         {
  5.             gvEmployees.UseAccessibleHeader = true;
  6.             gvEmployees.HeaderRow.TableSection = TableRowSection.TableHeader;
  7.             gvEmployees.FooterRow.TableSection = TableRowSection.TableFooter;
  8.         }
  9.     }

If you are using grid view in update panel and binding it in a call back, then it’s better to put it in gridview’s databound event,

  1. protected void gvEmployees_DataBound(object sender, EventArgs e)
  2.     {
  3.         if (this.gvEmployees.Rows.Count > 0)
  4.         {
  5.             gvEmployees.UseAccessibleHeader = true;
  6.             gvEmployees.HeaderRow.TableSection = TableRowSection.TableHeader;
  7.             gvEmployees.FooterRow.TableSection = TableRowSection.TableFooter;
  8.         }
  9.     }

Now download and include the jQuery and TableSorter js files as follows

  1. <script type=“text/javascript” src=“scripts/jquery-latest.js”></script>
  2. <script type=“text/javascript” src=“scripts/jquery.tablesorter.js”></script>

Initialize the table for sorting when document is ready using the below code,

  1. $(document).ready(function()
  2. {
  3.     $(“#gvEmployees”).tablesorter();
  4. });

If you are using update panel, you need to consider using pageLoad function(javascript)

  1. function pageLoad(sender, args)
  2. {
  3.     $(“#gvEmployees”).tablesorter();
  4. }

At this point the sorting should work on client side, Now you would want to set ascending and descending icons for grid headers. You could easily do this by defining these styles in your style sheet.

  1. .headerSortUp
  2. {
  3.     background-position:top;
  4.     background-repeat: no-repeat;
  5.     background-image: url(../images/icons/sort_up.gif);
  6.     background-color: #e9e7d7;
  7. }
  8. .headerSortDown
  9. {
  10.     background-position:top;
  11.     background-repeat: no-repeat;
  12.     background-image: url(../images/icons/sort_down.gif);
  13.     background-color: #e9e7d7;
  14. }

Or you could use the styles that comes with Tablesorter as follows, just set the gridView cssclassname to tablesorter

gvEmployees.CssClass = “tablesorter”;

and include the stylesheet as follows

<link rel=“stylesheet” type=“text/css” href=“themes/green/style.css” />

Tablesorter provides lots of config options, here are few important ones,

sortList: [0, 1] — This instructs to sort by index 0 column in descending order.

dateFormat: “uk” — if your format is dd/MM/yyyy, it does not seem to work by default for this format.

debug: true — this option provides you information like how much time it took and how(what type) it considered the columns.

  1. $(“#gvEmployees”).tablesorter(
  2. {
  3.     debug: true, //provides debugging information
  4.     sortList: [[0, 1]], //sorts 0th column by descending order
  5.     dateFormat: “uk”, //sets the date format to dd/MM/yyyy
  6. });

Now some interesting things, if you have columns that are formatted differently like having a thousand separator. We could use a customParser in this scenario, otherwise the data would be considered string and the sorting would not work as expected.

We should define a customParser with an id and then assign it to a column while initializing tablesorter.

  1. //define a parser
  2. $.tablesorter.addParser(
  3. {
  4.     // set a unique id
  5.     id: ‘formattedNumbers’,
  6.     is: function(s)
  7.     {
  8.         // return false so this parser is not auto detected
  9.         return false;
  10.     },
  11.  
  12.     format: function(s)
  13.     {
  14.         // format your data for normalization
  15.         return s.replace(/,/g, ); //removes comma separator from formatted numbers
  16.     },
  17.     // set type, either numeric or text
  18.     type: ‘numeric’
  19. });
  20.  
  21. //initialize table for sorting
  22. $(“#gvEmployees”).tablesorter(
  23. {
  24.     headers:
  25.     {
  26.         6: { sorter: ‘formattedNumbers’ }
  27.     }
  28. }) 

There might be templated columns and checkbox bound fields in the gridview and if we need to do sorting for those columns, we could do so by using textExtraction. textExtraction is similar to customParser but this applies to the whole table and gets node instead of a string for processing. Here is some code that will process templated text columns and checkbox bound columns.

  1. //define a function for extracting text from node
  2. function extractValue(node)
  3. {
  4.     var children = node.childNodes[0].childNodes.length
  5.    
  6.     if (children == 0) //boundTextField or a templateColumn
  7.     {
  8.         if (node.childNodes[0].nodeType == 3)//boundTextField
  9.         {
  10.             return node.childNodes[0].data;
  11.         }
  12.         else //template column
  13.         {
  14.             var type = node.childNodes[0].type
  15.             switch (type) {
  16.                 case “checkbox”:
  17.                     return node.childNodes[0].checked.toString();
  18.  
  19.                 case “radio”:
  20.                     return node.childNodes[0].checked.toString();
  21.  
  22.                 case “text”:
  23.                     return node.childNodes[0].value;
  24.                    
  25.                 default: return “”
  26.             }
  27.         }
  28.     }
  29.     else //boundCheckboxColumn or a templateLabelColumn
  30.     {
  31.         if (node.childNodes[0].childNodes[0].nodeType == 3)
  32.         {
  33.             return node.childNodes[0].childNodes[0].data;
  34.         }
  35.         else
  36.         {
  37.             return node.childNodes[0].childNodes[0].checked.toString();
  38.         }
  39.     }
  40. }
  41.  
  42. $(“#gvEmployees”).tablesorter(
  43. {
  44.     textExtraction: extractValue
  45. })

This covers most of things that one would do in gridview. The download contains all the above mentioned code.

Points of Interest

The Tablesorter is very good for the kind of functionality it provides with so much less code & effort. I am sure more and more people would be interested in this and would be using this as Microsoft recently announced it’s support to jQuery

It’s very simple to create an extended gridview control built with these functionalities.

You could download the sourcecode for sample from here Download 

Ponnu

←Older