Welcome

You have reached the blog of Keith Elder. Thank you for visiting! Feel free to click the twitter icon to the right and follow me on twitter.

Speaking at Huntsville, AL Code Camp February 23rd

Posted by Keith Elder | Posted in Presentations, Speaking | Posted on 03-02-2008

image February 23rd, 2008 a plethora of knowledge will descend upon Huntsville, AL for the Alabama .Net Code Camp 6.0 event.  Speakers are traveling as far away as Tennessee, Alabama, Georgia and Mississippi to put on the code camp.  If you are within the general vicinity of Huntsville you should take advantage of this opportunity.

For more information about the line up of speakers and sessions planned, visit the Alabama Code Camp web site.

Event Details

Location:
Virginia College at Huntsville
Network Engineering Department
2800a Bob Wallace Avenue
Huntsville, AL 35805

When:

7:30AM – 5PM

Registration:

https://www.clicktoattend.com/invitation.aspx?code=124330

I will be speaking on four topics that day which revolve around Smart Clients and Workflow Foundation.  Two on each.  I missed last years code camp in Huntsville due to some other travel so this is my first time to do a code camp in Huntsville. I am looking forward to it.  See everyone on the 23rd!

Debugging Vista Sidebar Gadgets in Visual Studio 2008

Posted by Keith Elder | Posted in Vista Gadgets | Posted on 31-01-2008

I’ve recently been digging into writing Sidebar Gadgets for Windows Vista.  As a client developer mainly, writing a gadget has brought me back to my Javascript / HTML / DHTML / CSS roots.  Over the next several weeks I’ll be writing some entries on my experience writing gadgets but before I get into the gory details let’s talk about debugging.  For those of you that are starting out writing gadgets the first thing you are going to run into is how to debug them. 

Overriding Alert

Once you get your initial gadget setup (which I’ll cover in a later blog post) you will no doubt run into a JavaScript error along the way.  For those familiar with JavaScript, the alert() function is classic favorite to view variables.  The alert function allows a developer to pass in something like the following:

alert(“That’s some good code there paw paw!”);

This will print a dialog box with the message.  The problem is that within gadgets this function doesn’t work.  To circumvent this shortcoming the first thing that must be done is create an override function for alert().  Within the alert function we’ll be writing to System.Debug.outputString(msg) to print the variable we need to debug.  As a side note, I suggest creating another variable to turn this on or off so you don’t have to go back through all of your JavaScript and comment this line out.

var debug = true;
function alert(msg)
{
    if (debug)
    {
        System.Debug.outputString(msg);
    }
}

More information on System.Debug can be found here:

http://msdn2.microsoft.com/en-us/library/aa359287(VS.85).aspx

Once the new alert function has been established the messages passed to the new alert() method can be viewed by running DebugView.  DebugView is a utility to view low level messages as the gadget is running (as well as other things).  For those not familiar with DebugView here is a description taken from the Microsoft site:

DebugView is an application that lets you monitor debug output on your local system, or any computer on the network that you can reach via TCP/IP. It is capable of displaying both kernel-mode and Win32 debug output, so you don’t need a debugger to catch the debug output your applications or device drivers generate, nor do you need to modify your applications or drivers to use non-standard debug output APIs.

Here is an example of debugging a gadget with DebugView:

image

Setting Up Internet Explorer to Debug

Before we can start to truly debug gadgets a couple of settings need to be adjusted within Internet Explorer.  The advanced settings of IE can enable scripting to be debugged and this is important because Sidebar uses the IE engine to render gadgets.  Within IE go to Tools->Internet Options and click on the advance tab.  Within the browsing section, uncheck the two “Disable script debugging….” options as shown here.

image

No when a JavaScript error occurs you will get the following screen:

image

The reason we need to do this is because gadgets are running within the Sidebar executable and if this is disabled error messages will never appear and never give us a chance to debug.  When this dialogue appears, clicking yes will then present the Visual Studio Just-in-Time Debugger as shown later on which will then allow you to select a Visual Studio instance to debug with.

Taking Advantage of VS2008’s JavaScript Features

Visual Studio 2008 provides a lot of rich JavaScript support.  While it isn’t perfect it is a great start to allow web developers to be able to step through JavaScript code.  It is important to note that although VS2008 supports break points for JavaScript within a web solution, sidebar gadgets are not running within the Visual Studio process.  Because of this, if you want to debug at a certain point within a gadget you have to add the line debugger where you want to start debugging.  Again, setting a break point will do you no good since the gadget is running in another process.  Once the line where debugger is hit a screen will pop open from Visual Studio to start debugging.  Here’s a sample.

function setup()  
{
    // this will start the debugger for VS2008
    debugger;
    alert("init() was called");
           
    // set background of gadget
    var oBackground = document.getElementById("imgBackground");
    oBackground.src = "url(Images/background.png)";
    alert("background set");
    
    // do something cool
    saveTheWorldFromPoliticians();    
}

Once this line is hit a screen will appear like the following:

image

In the example above an instance of Visual Studio is grayed out and is the instance the solution for the gadget is running from.  I find it better to use this one than loading a new instance.  Selecting it and pressing yes will open the existing solution at the line where the debugger statement is called.

image

From there it is normal Visual Studio debugging by pressing F10 and or F11.  All of the features of debugging such as Quick Watches and break points allows developers to preview variables as was introduced for C# and VB in Visual Studio 2005.  Here is a sample of stepping through an init() method and hovering over the oBackground variable:

image

How cool is that?!  A full object model is displayed along with supporting methods and events of the object.  Very cool no doubt and extremely useful viewing the state of your objects. 

Attaching To Sidebar Gadget Instance

If you have a gadget already running within the sidebar you can attach to the sidebar process from within Visual Studio and simply hit a break point within your code.  To do this go to the debug menu in VS and then press “Attach to process”.  Remember your gadget should already be running within sidebar.  In the available processes area select the gadget running within sidebar as shown here:

image

Once attached to the instance of your gadget you can hit breakpoints within your Javascript without the need for the debugger line.

Later on I’ll post some more tips and tricks on building gadgets for Vista but I figured I’d post something on debugging them first since that is literally where I have spent 95% of my time lately.

 

Technorati tags: , ,

Gmail IMAP Fixed For Windows Mobile

Posted by Keith Elder | Posted in Mobile Devices | Posted on 30-01-2008

Several days ago I announced I had moved to Google Apps for email mainly because of IMAP support.  One of the problems I had was reading mail on my Blackjack II phone. 

The problem was wide spread because of the way Gmail handled IMAP with Windows Mobile phones.  When an email was read via IMAP on the phone, the email would be blank.  It appeared to only affect HTML formatted email which meant Gmail was doing something weird with the email instead of just leaving it alone.  When I first discovered this I thought I didn’t download the email or I configured something incorrectly.  Searching around Gmail I learned that others had the same problem so  I did the only thing I could do, I voted on the fix.  

Earlier today I noticed that I was able to read all of the emails I selected.  Curious I got confirmation when I stumbled upon this article explaining that indeed the problem had been fixed. 

Let’s see.  Google announced IMAP support back in October so that’s about 4 months of broken IMAP support on Windows Mobile phones.  Four months to fix what should be a simple, works on every other IMAP server I have ever freaking used?  I hope nothing else breaks, this doesn’t leave me warm and fuzzy Google.

Two Form Tags in Asp.Net and My Work Around

Posted by Keith Elder | Posted in Asp.Net | Posted on 26-01-2008

I can’t remember the exact day but a few weeks ago around the start of the new year I changed out the site’s search to use Google’s search engine for AdSense.  Not thinking when I pasted the code I broke the comments and my contact form on the site for all Internet Explorer users.  The sad thing is I didn’t notice this until the other day when I started getting emails their was a problem.  For everyone that tried submitting comments and it not work I apologize.

The problem was when I pasted the Google AdSense Search code into my template it had a complete form tag thus giving me two form tags nested within each other.  After the paste I wound up with something like this.

<form runat="server">
    <!-- GOOGLE SEARCH -->
    <form method="get" action="someurl>
    </form>
</form>

With Asp.Net only one form tag is allowed within the body of a page and this is a topic that comes up a lot within Asp.Net forums and discussions.  There are ways around it like the one discussed on this article.  It isn’t an end of the world limitation just something you have to know or think about as you design your pages.

The way Google AdSense search works is when someone uses the search box in the top right of the site they are redirected to a page on my site that I control the layout on (this I like).  In my case it is called SearchResults.aspx.  Within that page there is JavaScript that takes the parameters via the URL and passes them into Google’s search specific for my site.  Results are then returned within the page within my site.  The end result is seamless to the end user and this cuts down on database work for my server.  But since I had two form tags in my html things were broke. 

Disclaimer:  The following is a hack that worked for my situation and may not work for all scenarios, use it at your own discretion.

After I figured out the problem I removed the Google start and end form tags.  Then I created a JavaScript function that took in an action and a method that would be used to replace the current one on the single form tag.  Here’s the JavaScript I added into the site.

<script type="text/javascript">
//<![CDATA[
function changeActionAndMethodOnFormAndSubmit(newAction, newMethod)
{
    var theForm = document.forms['Form1'];
    if (!theForm) {
        theForm = document.Form1;
    }
    theForm.action = newAction;
    theForm.method = newMethod;
    theForm.submit();
}
//]]>
</script>

Then within the Google code I added the function using the onclick event like this:

<input onclick="changeActionOnFormAndSubmit('http://keithelder.net/SearchResults.aspx', 'get')" type="submit">

After I uploaded the changes I typed something into the search and got results back.  Yeah.  I then tested in Firefox and IE7 and my hack worked.

 image

The only problem with this approach is there is a lot of other hidden form fields getting passed over in the URL.  Mostly view state and event argument stuff.  While not perfect this quick fix worked for my scenario which is good since I really didn’t want to mess with the main source code of the site.  The only reason I even posted this is in case someone needed a quick fix / work around as well.

Visual Studio 2008 Seminar in Jackson, MS and Geek Dinner in Hattiesburg on Feb 4th

Posted by Keith Elder | Posted in Presentations, Smart Clients, Speaking | Posted on 25-01-2008

Doug Turnure, Chad Brooks and me are doing a half-day technical overview covering the new features surrounding Visual Studio 2008 in Jackson, MS from 9:00 AM to 12:00 PM on February 4th, 2008.  Then later that night we are having a Geek Dinner with special guest Sara Ford in Hattiesburg, MS.  Here are the details and how to register for the seminar (yes you HAVE to register for the seminar).  You do not have to register for the Geek Dinner but please RSVP as described.

Seminar Agenda

9:00 – 10:00: Visual Studio 2008 Overview for Architects (Chad)

If your job as a Software Architect is to research and exploit technology to help achieve business results – then you need to take a look at what has just been released in Visual Studio 2008 and the .NET Framework 3.5.   In this talk we will discuss several of the many new features you need to understand and explore to be able to fully leverage these new capabilities in your environment, including multi-targeting support, new features for SOA, and web enhancements. Finally, we will discuss the road ahead and preview some of the local architect, web design, and developer events that you can use to help further your understanding of Microsoft platform and development technologies.

10:00 – 11:00 Visual Studio 2008 and the .NET Framework 3.5 (Doug)

Visual Studio 2008 has shipped, and with its arrival, there are several new features in the framework, compilers, and the IDE itself. In this technical overview, we will discuss some of the new developer productivity enhancements in Microsoft Visual Studio 2008. We’ll explore new designers that assist developers in creating applications more quickly and easily. We’ll also take a look at LINQ, and the benefits it provides.

11:00 – 12:00 Visual Studio 2008: New Developer Productivity Enhancements (Keith)

Learn what is new in Visual Studio 2008 when it comes to building Smart Clients.  We’ll take a look at several new enhancements and improvements developers can take advantage of in Visual Studio 2008.  In this session we’ll look at several things such as Client Application Services, new improved ClickOnce features, offline and online data syncing and more.

Location

New Horizons Computer Learning Center
1855 Lakeland Drive
Suite R101
Jackson, MS 39216

Phone: 601-914-4500

Registration
http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032367675&Culture=en-US

Or by phone:  877-673-8368 and reference Event ID:  1032367675

Geek Dinner Agenda

7:00 – 10:00 Geek Dinner in Hattiesburg with Sara Ford

Location

Chesterfields’ Restaurant
Hattiesburg, MS

For more information about the dinner including directions, and how to RSVP for dinner please visit previous Geek Dinner announcement on this site.