A day in the life (of a developer) RSS 2.0
 Saturday, April 19, 2008

 

I admit it - the above comic could be about me. I can be easily distracted by shiny things, so I sometimes have to fight off the urge to spend way too much time playing around with some cool bit of technology, code, or idea. If you're like me, these links may be your downfall. Lot's of things to sidetrack you with. The site I snagged the above comic from is just one of them.

http://www.xkcd.com

MIX is a web development conference put on by Microsoft. They've made all (well, at least I think it's all of them) of the conference topics available online. Very cool - there are bunch of really good sessions available here. Silverlight is looking interesting.

http://visitmix.com/

The TED (Technology, Entertainment, Design) conference is a four day conference with one "track" of speakers that each get 18 minutes to there thing. From what I've gathered, it's mostly an "invite only" type of event of around 1000 people (and even if it wasn't, the $6000 membership fee would probably keep the number of people attending under control). At any rate, they've made something like 200 of the talks available for free, so there are a ton of interesting videos to watch here. Since they're all under 18 minutes, it's easy to fit a video or two in a sitting. Then you can waste another few hours Googling some of the things they talk about.

http://www.ted.com

Google Earth - An "oldie" but a goodie. I can waste a ton of time with this one. Something about the interactivity of it really appeals to me. I can't say I was ever really a map-person until apps. like this and GPS became readily availble. And if you get bored, there are a bunch of neat 3D buildings and map overlays to download. Zoom in, zoom out, zoom in, zoom out...

http://earth.google.com/

Photosynth - If Google Earth appeals to you, you'll probably also love this one. It's basically a Microsoft research project (well, Microsoft owns it now) that takes pictures of some scene and projects it (or builds it, I'm not exactly sure) onto a 3d framework of the original location. Check out the Collections they've got - I swear I wasted a good 45 minutes rotating and zooming into the images. Even if you've seen this in the past, visit it again: they've added a few new collections that are pretty cool.

http://labs.live.com/photosynth/

The above should keep you busy for a while. I had planned on "featuring" a timewaster once a week or so, but at my current blogging pace it'd probably be closer to once a month, so I decided to just group a bunch of the more general ones together into one post. Have fun.

Saturday, April 19, 2008 7:07:00 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

Other
 Tuesday, April 15, 2008

One request that comes up from time to time is to embed a checkbox inside of an ASP.NET grid control for boolean data.

Unfortunately, one of the downsides to this is that the controls are "read only" - they don't let you check or uncheck them

without putting the row into edit mode. That works, but in some cases this isn't all that great either. What do you do if you just want a checkbox on each row, that's "live" and causes a postback as you check/uncheck items? Thankfully this doesn't take much code but figuring out the first time can be really painful. To get the "live" checkbox, just wrap it inside of a template. (In the example code I created a new Web Form named "GridCheckbox").

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

 

<!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 id="Head1" runat="server">

    <title>Untitled Page</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>       

        <asp:GridView runat="server" ID="grdList" AutoGenerateColumns="false"

            onrowdatabound="grdList_RowDataBound">

            <Columns>

                <asp:TemplateField>

                    <ItemTemplate>                       

                        <asp:CheckBox runat="server" ID="chkItem" Checked='<%# Container.DataItem %>' AutoPostBack="True" OnCheckedChanged="CheckChanged"/>                                              

                    </ItemTemplate>

                </asp:TemplateField>

            </Columns>

        </asp:GridView>

    </div>

    </form>

</body>

</html>

 

Make sure you set the "AutoPostBack" to true. Then set it's OnCheckedChanged event handler to call your server side code.

Now let's add some code to the Page_Load to give our grid something to bind to:

protected void Page_Load(object sender, EventArgs e)

{

    bool[] items = { true, true, false, false, true };

    if (!Page.IsPostBack)

    {

        this.grdList.DataSource = items;

        this.grdList.DataBind();

    }

}

 

 

In my example code, I'm just binding to a simple boolean collection to keep things simple. Now we need an event handler to respond to our checkbox event:

protected void CheckChanged(object sender, EventArgs e)

{          

}

 

The code doesn't do anything yet but at this point you might be wondering how we figure out which checkbox we checked - normally, your grid is bound to a different row in some table. Each checkbox is related to that specific row. How or where do we get that from? The grid isn't much help in this case because it's not raising the event. If we were using a Button we could set it's CommandName and/or CommandArgument properties to hold something like the primary key of the row in our table. The checkbox control doesn't have any such properties. ASP.NET controls have an InputAttributes collection where you can place name/value pairs - this information is passed to the client (and back to the server), so it makes this relatively painless.

First, add an event to onRowDataBound of the grid (already shown in the ASPX above). Now add the event in our code-behind:

protected void grdList_RowDataBound(object sender, GridViewRowEventArgs e)

{       

}

 

We can't reference the control directly by name, since it was embedded in the grid and ASP.NET has made sure it's uniquely named. Let's use the FindControl method to do this. I've also added the code to add a Value attribute and added a member called m_row. I'm just using this so we can have a different value on each and every row of the grid. In a real application this is where you'd pull the primary key value from your datasource (probably using e.Row.DataItem).

private int m_row = 0;

protected void grdList_RowDataBound(object sender, GridViewRowEventArgs e)

{

    CheckBox chk = e.Row.FindControl("chkItem") as CheckBox;

 

    if (chk != null)

        chk.InputAttributes.Add("Value", this.m_row.ToString());

    this.m_row++;

}


Now we're just about done - all that's left is retrieving this value back on the server when the Checkbox is checked or unchecked:

protected void CheckChanged(object sender, EventArgs e)

{

    CheckBox chk = sender as CheckBox;

    string val = "";

    if (chk != null)

        val = chk.InputAttributes["Value"];

}


So our completed codebehind page looks like this:

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

 

namespace WebApplication1

{

    public partial class GridCheckbox : System.Web.UI.Page

    {

        private int m_row = 0;

        protected void Page_Load(object sender, EventArgs e)

        {

            bool[] items = { true, true, false, false, true };

            if (!Page.IsPostBack)

            {

                this.grdList.DataSource = items;

                this.grdList.DataBind();

            }

        }

 

        protected void CheckChanged(object sender, EventArgs e)

        {

            CheckBox chk = sender as CheckBox;

            string val = "";

            if (chk != null)

                val = chk.InputAttributes["Value"];

        }

 

        protected void grdList_RowDataBound(object sender, GridViewRowEventArgs e)

        {

            CheckBox chk = e.Row.FindControl("chkItem") as CheckBox;

 

            if (chk != null)

                chk.InputAttributes.Add("Value", this.m_row.ToString());

            this.m_row++;

        }

    }

}

Now when you run this every time you check or uncheck an item you should see the page post-back (set a breakpoint on CheckChanged). You can now update your data, or whatever else you need to do in response to this event.
Tuesday, April 15, 2008 9:18:15 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

ASP.NET
 Friday, April 04, 2008

This has hit me more than once already. If you create an HTTP Handler (ASHX) file, by default the context object reference (passed in to ProcessRequest) doesn't contain a reference to the Session object, so attempting to access context.Session will fail.

The fix is to add a "using System.Web.SessionState" to the using section, then inherit from the IReadOnlySessionState interface.

 

Ex.

 

using System.Web.SessionState;

public class MyAshx : IHttpHandler, IReadOnlySessionState
{

}

 

This will give you read only access to the session state. If you need to add to the session, inherit from IRequiresSessionState instead.

Friday, April 04, 2008 6:15:49 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

ASP.NET
 Thursday, April 03, 2008

I've been playing around a bit with WPF lately (with Visual Studio 2008) and was disappointed that there wasn't any intellisense in the designer (like what you'd see in the ASP.NET designer). I happened to mention this on the UT and John Fenton there pointed me to this link:

 

http://blogs.msdn.com/windowssdk/archive/2008/02/22/workaround-installing-win-sdk-after-vs2008-breaks-xaml-intellisense.aspx

 

Apparently installing the Windows SDK after installing VS2008 breaks XAML intellisense. The link above walks through fixing it (very simple registry entry fix).

 

Links

 

http://www.universalthread.com
http://blogs.msdn.com/windowssdk/archive/2008/02/22/workaround-installing-win-sdk-after-vs2008-breaks-xaml-intellisense.aspx

Thursday, April 03, 2008 8:19:19 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

Visual Studio | WPF
 Sunday, March 23, 2008

I've finally gotten all set-up in Microsoft's Empowerment program. I wish I could say it went smoothly, but that definitely wasn't the case. I think I may have signed up at the worst possible time - they were in the process of revamping their website which caused me a bunch of different problems. I finally got tired of playing e-mail tag and called Partner support a few weeks ago. They had been telling me to complete the application process, but every time I tried to log back into the Empowerment site it just told me my application had been denied and it wouldn't let me sign back up (or even tell me WHY it had been denied). When I called they took a look at it then told me they needed to have someone else take a look at the problem. I received an e-mail a few days later claiming the problem should be resolved.

I tried logging back in but had the same problem I had been having. I called them again two weeks ago Monday and while I was on the phone they were finally able to clear whatever flag was keeping me from being able to resubmit my application - they definitely added a few more required fields from when I initially signed up. Last Monday I figured I'd try logging back into the Partner site and see if they had any way of checking the status. I ended up trying to sign up again but this time I got to a page which wanted me to agree to some EULA, but the buttons were all disabled. Was that a good sign or a bad sign?

I found out two days later (on Wednesday) when I received my Empowerment CD's and DVD's. Unfortunately, they don't include any kind of documentation about how to actually get your license keys. Since I've worked at a few places which had their Universal subscription (when it was available), I assumed I might just be able to log into the MSDN subscriber download section using my MS Live ID. I clicked on the "Associate your subscription with your WIndows Live ID" link but it also wanted me to enter my

MSDN

Benefit Access Number, Subscriber ID, or MSPP Technical Contact ID. Unfortunately I didn't receive anything labeled that way in the kit they sent me. I tried using my partner ID and my MCP ID, neither of which worked. I dug through the partner website and found that I actually had a "Technical ID" associated with my name. To find this - log into the partner site and click on the "Requirements & Assets" menu at the top, then select "Associated People"

PartnerAssoc

At the bottom of the screen that opens is a list of all people associated with your company and their technical ID. I tried entering this and it unfortunately didn't work. I thought (maybe) the site required a Live ID e-mail address instead of my other e-mail address, so I entered it instead and saved it. Then I tried signing in again. At that point the site complained that I had entered the wrong info. in too many times and to try again in 5 minutes. At that point I gave up.

The next day I dug up the MSDN support number and gave them a call. They had me re-enter the information I had tried the night before, fiddled with a few things and suddenly it let me log in!

I know someone who is planning on signing up as well and I'm curious to see if it goes smoother for them than it did for me - hopefully it does.

 

Links:

http://www.rcs-solutions.com/blog/2007/10/12/MicrosoftsEmpowerProgramForISVs.aspx
http://www.rcs-solutions.com/blog/2007/11/20/EmpowermentProgramUpdate.aspx
https://partner.microsoft.com/40011351
http://msdn2.microsoft.com/en-us/default.aspx

Sunday, March 23, 2008 12:05:40 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

Software
 Sunday, March 09, 2008

Wow, local DAFUGer Frank Perez has actually posted new content on his blog. He's worse than I am with keeping it updated regularly (and I'm pretty sure only 3 or 4 people even knew he HAD a blog; that probably keeps the pressure to update it regularly to a minimum). Anyway, he's showing off a neat plug-in tool for Beyond Compare that let's you run comparisons against various VFP-specific filetypes (DBF/MNU/SCX/VCX among others). Check it out.

Links:

http://www.dafug.org
http://www.pfsolutions-mi.com/blog/2008/03/08/BeyondCompare.aspx

Sunday, March 09, 2008 10:48:44 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

VFP
 Saturday, March 08, 2008

We ran into an interesting performance issue a few weeks back. We had migrated our primary fileserver over to a new machine (it was previously running on the same machine as our website). We expected some of the pages on our website to be a bit slower since the files were no longer on the same box (we have both data in VFP and in SQL Server 2005), but some of them were suddenly painfully slow. They went from 1-2 seconds to more than 7+ seconds. We talked about installing a dedicated network card to link two servers to help, but it still didn't seem like the performance should take that much of a hit.

My boss spent some time tracing the problem and found it was really slow when we opened the company file from our accounting system (Sage Pro). I've talked about the performance of USE in the past, but it was still amazing to see how slow it was. He tried using a mapped drive and UNC mapping but the performance of each was about the same. This particular table is part of a database, so he tried prefixing the USE statement with the database name, ex. USE F:\PathTo\Data\MyDatabase!MyTable IN 0 - the difference was amazing. That 7+ seconds dropped back down to 1-2 seconds: a bit slower than it was when it was local, but still much faster than it had been. Resolving the database is apparently very slow.

Saturday, March 08, 2008 2:16:34 PM (Eastern Standard Time, UTC-05:00)  #    Comments [2] -

VFP

I was just checking out the PPCGeeks website, checking up to see if anyone had any status updates on the Sprint Mogul PPC. I've had this phone since late August, and have been waiting for a promised upgrade which is supposed to finally enable the built-in GPS-A support and support for EVDO Rev A. It finally looks like it may actually see the light of day on Monday, according to this post. It would have been nice to have had it released on Friday so I'd have the weekend to get it installed and get my phone customized again, but as a developer, I can appreciate not doing a release on a Friday.

I'm hoping Google Maps will support the built-in GPS. I've got an external blue tooth GPS I could use, but it's just not as convenient as something built-in. I'm not really looking forward to reinstalling all of my applications and customizing it with the HTC Touch interface (which is a MUCH nicer interface than the stock one), but thankfully this isn't something I have to do on a regular basis.

Links:

http://forum.ppcgeeks.com/showthread.php?t=20363
http://www.america.htc.com/support/mogul/software-downloads.html
http://www.google.com/gmm

Saturday, March 08, 2008 2:00:09 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

Cellphones
 Sunday, February 10, 2008

I just uploaded a new version of the VFP calendar. I've fixed the problem where the drop-down version of the calendar wouldn't collapse if you clicked away from it. I initially thought it would be a simple matter of just adding some code to the calendar form's LostFocus event. That appeared to work, but had the side effect of breaking the drop-down button. If the calendar was being displayed and you then tried to click on the drop-down button to hide the calendar, the LostFocus would fire (hiding the calendar), then the Click event of the button would fire which would redisplay the calendar. Not quite what I was expecting.

I experimented with a few different ways of attempting to address this, but I just couldn't get the events to fire the way I wanted. Ultimately, I ended up adding code in the Click event to save off the last time since the calendar was hidden. If it is under the configured minimum interval, we don't do anything (the assumption is the the LostFocus just fired and hide the calendar). If the interval has been exceeded, the calendar is displayed as normal. A little weird, but relatively simple to code.

I've also added another sample to show how the rcsDateTimePicker controls can be hooked together for Start/End date scenarios. The controls keep the start date from being later than the ending date. The parent (Start) / child (End) relationship is setup via two properties on the control: uParentPicker and uChildPicker. These properties are evaluated to resolve to an object reference to the proper control.

 

Links

http://www.rcs-solutions.com/downloads.aspx

Sunday, February 10, 2008 1:17:16 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

VFP
 Sunday, January 13, 2008

I'm happy to say my winter cleaning give away was a success. Almost all of the books that were available have new owners (although they may still be waiting for them, since they were shipped at the book rate which can take forever), and my huge pile of computer equipment is also gone. I had a taker for the computer equipment within a day of posting it on my local Freecycle site. I thought he'd pick through the rubble, but he ended up taking the whole pile (including my Windows NT 3.51, NT 4.0, and Windows 2000 Resource Kits - those alone took up a full bookshelf).

There are a few books still available, if anyone is interested.

Img_4417

 

Links:

http://www.rcs-solutions.com/blog/2007/12/13/WinterCleaning.aspx
http://www.freecycle.org

Sunday, January 13, 2008 5:33:56 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

Other | VFP

I was just reading some of the threads over on the UT and ran across one where someone was looking for a drop-down calendar control. Someone suggested they look at the one that I've got in the downloads section on my site. Unfortunately, the version I've had up forever doesn't actually have a "drop down" version of the control. I've had an updated version for a long time now, but I've never gotten around to posting it (until now). This thread kicked me in the butt a little to update this on the site.

Here's a screenshot of the updated control:

DropdownCalendar

Hopefully you find it useful.

 

Links:

http://www.universalthread.com
http://www.rcs-solutions.com/Downloads.aspx

Sunday, January 13, 2008 5:17:45 PM (Eastern Standard Time, UTC-05:00)  #    Comments [3] -

VFP


Navigation
Archive
<July 2008>
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Paul Mrozowski / RCS Solutions, Inc.
Sign In
Statistics
Total Posts: 38
This Year: 13
This Month: 0
This Week: 0
Comments: 14
All Content © 2008, Paul Mrozowski / RCS Solutions, Inc.
DasBlog theme 'Business' created by Christoph De Baene (delarou)