JavaScript delete confirmation with the C1 ASP.NET GridView

By James at November 08, 2010 23:04
Filed Under: JavaScript, C1GridView, ASP.NET

The ComponentOne ASP.NET GridView allows you to add a Delete button to remove a record from the DataTable. However there isn’t a native way to add a confirmation that you really want the record deleted. It’s always best to check for sure when it comes to destructive actions, so I did some spelunking and came up with a way to do it.

1. Add a Template Field column to the grid by using either the property builder, or in the declarative code of your .aspx page.


2. Go into source view and add an ItemTemplate, then an asp:ImageButton.

          <ItemStyle Width="25px" VerticalAlign="Top" />
               <asp:ImageButton ID="lbDelete" 
                  ImageUrl="~/Images/delete.gif" />

3. In the main C1GridView declaration add a method for the OnRowDataBound event. In this case I added the following:


4. Add your method to the code behind:

   protected void AddJavaScriptConfirm(object sender, C1GridViewRowEventArgs e)
        C1GridViewRow row = e.Row;
        ImageButton imageButton = (ImageButton) row.FindControl("lbDelete");
        if(imageButton != null)
          "java-script:return confirm('Are you sure you want to delete this record?')" );

What this does is for every row that is databound it finds the ImageButton with the ID of “imgDelete” then adds the “onclick” attribute to the element when it is rendered as html

     <td class="C1Gtd" valign="top" style="width:25px;">
          <input type="image" name="ctl00$MainContent$C1GridView1$ctl01$ctl07$lbDelete" 
             id="MainContent_C1GridView1_lbDelete_4" src="Images/delete.gif" 
             onclick="java-script:return confirm(&#39;Are you sure you want to 
               delete this record?&#39;);" />

NOTE: I had to change javascript to java-script as this blog system sees it as a potential threat. If you copy this code, change the java-script back to javascript.



That’s it. Easy, peasy, nice and cheesy.

Happy programming,


So Cal Code Camp–USC

By James at October 25, 2010 21:12
Filed Under:

I love code camps, especially the So Cal Code Camps. Yup, that’s plural as Southern California is lucky enough to have three per year. Last weekend, October 23-24 was So Cal Code Camp – USC and I was lucky enough to get the chance to present again. I gave the same presentation as what I did at Silicon Valley Code Camp three weeks ago – ASP.NET MVC and Entity Framework 4 – but this time it went a whole lot smoother. The room was ready, the projector was working correctly, and the audience was right on. Just about 50 attendees with standing room only and five people sitting on the floor. I brought along six of our C1 beanies which I tossed out during my talk to people who made good comments, pointed out different ways to do things, and laughed at my jokes.

I also manned the ComponentOne booth during the day and had a great time talking to the wide variety of Code Campers about our products, passing out literature, key chain carabineers, and our magic “wear these and you’ll never write bad code again” sunglasses.

Thanks to Art Villa and everyone who helped to put on a successful event. It’s a lot of work and they all deserve a big round of applause. And a special thanks to my wife, Carmina, (my own personal booth babe) who took over for me when I went to present.



My slides are at, and if you happened to be in attendance, please take a few minutes to tell me what you thought of my presentation at


Watch your Azure Account

By James at April 29, 2010 03:57
Filed Under: Microsoft, Life in General, MVP

The other night, Carmina and I were at our computers taking care of business and stuff, when the following conversation took place.

Carmina: “James, what did you buy from Microsoft today?”

Me: “Um, nothing”

Carmina: “Microsoft just withdrew $315 from our checking account”

The transaction had a phone number so I called the next day. It was for my Azure account I had setup to play around with and do presentations on. When I started the account, I was asked to enter a credit card number as proof of identification, and since I have a MSDN account with my MVP, and that gives me 750 compute hours a month, I thought I was good.

Last month I received a notice from Microsoft Online Services that there had been a problem with my credit card. Wondering what that was all about, since I hadn’t been using the services I logged into the site to see what was going on. This is what I saw…

image  and I clicked on Subscriptions


then Actions, which had the following options, “View subscription details, Edit service details, Opt in to auto renew, and Edit billing information”. No where did I see anything to check on activity.

Back to the phone call. I was told in addition to Compute Hours there are also Upload charges and Storage charges, and even if an application is suspended on Azure, i.e. not active, it is still accruing storage charges. In addition, SQL Azure charges of $10 per month, are not included in the 750 hours/month which comes with my MSDN subscription.

Windows Azure Compute charges: $0.12 per hour
Windows Azure Storage charges: $0.15 per hour Yes, $0.15 per hour just to store the files even if the app is not running.

The moral of the story. Azure is a great platform, and I recommend you dive in and get comfortable with it. BUT, remember to take down your apps when you are done testing. Don’t leave them up there.

Oh yeah. Also take the time to look a little further on the portal. I didn’t see the tiny text the other times I was one the site.


Time to get a second job,


Hey! I’m an INETA Community Champion!

By James at April 05, 2010 10:39
Filed Under: Inland Empire .NET UG, Life in General

Wow. I woke up this morning to a terrific email…


We would like to extend our thanks for your participation in the INETA Community Champions program and your commitment to the developer community. You were nominated by your local Developer Evangelist Lynn Langit.  You faced some challenging competition yet your accomplishments speak for themselves.  The Community Champions team is thrilled to inform you that you are one of our top winners for Q1 2010.  Congratulations!  INETA will be announcing the winners in our next INETA Newsletter as well as posting announcements on our web site. 

I had worked with the INETA Community Champs committee a few years ago, but never thought I would be a recipient.

Thanks everyone, especially Lynn (my own developer champion)!

And just so everyone knows I’m not kidding… here’s the proof.

INETA Community Champions Badge

Time to get crackin’.


Interview questions – Change for a dollar

By James at March 22, 2010 12:19
Filed Under: Inland Empire .NET UG, Life in General, Technology in General

So, in my quest to become gainfully employed, I am going through the interview process, mainly technical interviews with hands-on developers. Unfortunately, they seem to want people that 1) either *just* graduated from Computer Science school, or 2) can memorize obscure bits of code, and recite the Visual Studio help files verbatim.

At my last interview, I walked in – after a two-hour car ride, and trying to find a parking spot – to a “Hi, let’s write some code on the white board” situation. Ok, I say to myself, “let’s give this a try”. Their first question, “write code to calculate the optimum number of coins to return when giving change after a purchase.”

Hmm, I think. And I stumbled around for a bit, eventually ending up writing some pseudo-code that involved some long division. The Inland Empire .NET User’s Group’s next meeting was the following Tuesday, and I decided to ask them the same question – however they had the luxury of being in a friendly environment with soda and pizza in their fiery little bellies.

Below are the two answers that UG members sent to me, and it got me to thinking. What I would like to do is have you write your code in the comments, so I can see how many different ways there are to write this method.

From member Daniel Lopez, “Just for grins. If you have suggestion on how to make it better, let me know.”

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GiveChange
      class Program
            static void Main(string[] args)

            private static void DoChange(double Tendered)
                  double _DecimalPart = Math.Round(1-( Tendered - Math.Floor(Tendered)),2);
                        if (_DecimalPart >= .25)
                              Change.Quarters += 1;
                              _DecimalPart -= .25;
                        else if (_DecimalPart >= .10)
                              Change.Dines += 1;
                              _DecimalPart -= .1;
                        else if (_DecimalPart >= .05)
                              Change.Nickles += 1;
                              _DecimalPart -= .05;
                              Change.Pennies += (int)(_DecimalPart * 100);
                              _DecimalPart -= _DecimalPart;
                  while (_DecimalPart > 0);

                  StringBuilder sb = new StringBuilder();

                  sb.Append(string.Format( "Quarters: {0}", Change.Quarters));
                  sb.Append(string.Format("Dines: {0}", Change.Dines));
                  sb.Append(string.Format("Nickles: {0}", Change.Nickles));
                  sb.Append(string.Format("Pennies: {0}", Change.Pennies));


      public  static  class Change
            public static int Quarters { get; set; }
            public static int Dines { get; set; }
            public static int Nickles { get; set; }
            public static int Pennies { get; set; }

And from member Henry Vander Leest, "Hi James, Was thinking about the comments you made at the meeting about the interview you had the the question about the code to make change. Well, here's my solution... I don't believe I could have written this in 5 minutes under stressful circumstances. Live Long and prosper."

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ChangeMaker1
    class Program
        static void Main(string[] args)
            //takes command line arg from 1 to 99 to make change for a dollar
            int quarters;
            int dimes;
            int nickels;
            int pennies;
            int tendered = 100;
            int cost = Convert.ToInt32(args[0]);
            int change = tendered - cost;
            quarters = change / 25;
            change -= quarters * 25;
            dimes = change / 10;
            change -= 10 * dimes;
            nickels = change / 5;
            change -= nickels * 5;
            pennies = change;
            Console.WriteLine("Quarters {0}, Dimes {1}, Nickels {2},  Pennies {3}, 
This is the change for item costing {4} cents",
quarters, dimes, nickels, pennies, cost ); } } }

I tested both, and they work like a champ. Now I just need to memorize these for my next round of interviews. So tell me, how would you do this “simple” exercise.

Time to work…


.NET Rocks is on the Road Again!

By James at March 18, 2010 03:46
Filed Under: Inland Empire .NET UG, Life in General

Man am I excited! Richard Campbell and Carl Franklin from .NET Rocks are going on the road again, and are making special plans to come out and visit the Inland Empire .NET User’s Group!

I’ve been working with – well he’s been doing all the work – Jim Barry at ESRI in Redlands to host the event there, and he has really come through for us. We will be having the event in the new Auditorium, which means the Inland Empire leg of the road trip will make all the other venues look like rickety old shelters.

(Update. I got so excited, I forgot the date)

Thursday, April 22, 2010 from 6:00 to 9:00-ish

Here’s a peek of what I’m talking about.

ESRI Auditorium

Go IE!

Here’s the “official” word from Richard and Carl…

.NET Rocks is on the Road Again!

Carl and Richard are loading up the RV and driving to your town again to show off the latest and greatest in Visual Studio 2010! And to make the night even more fun, we’re going to bring a rock star of the Visual Studio world to the event and interview them for a special .NET Rocks Road Trip show series. Along the way we’ll be giving away some great prizes, showing off some awesome technology and having a ton of laughs.

And one lucky person at the event will win “Ride Along with Carl and Richard” and get to board the RV and ride with the boys to the next town on the tour (don’t worry, we’ll get you home again!)

So come out to the most fun you can have in a geeky evening – and find out what’s new and cool in Visual Studio 2010!

Thanks Jim for all your help!

Keep an eye on to RSVP for the event

Time to get planning.

Windows Azure MSDN Event

By James at March 03, 2010 07:22
Filed Under:

Today I got to co-present with my great friend Lynn Langit at the Windows Azure MSDN Event at the Microsoft offices. I presented on “Real World, Hands-On SQL Azure”.

Here is my slide deck for your enjoyment. Real World SQL Azure


Presenting at the Rocky Mountain Tech Trifecta

By James at March 01, 2010 14:07
Filed Under:

I was invited to come and present at the Rocky Mountain Tech Trifecta in Denver, Colorado. It was the first time I'd been asked to present in a location not in Southern California and I was pretty jazzed about it. I've been working on a project mashing up a bunch of different technologies to generate Office 2007 format documents on a server and have built a pretty nifty presentation around that.

Things were going well, I had practiced and prepared, but then my laptop decided it DID NOT want to connect to the projectors provided. Well, not to be stopped by a silly little thing called technology, I looked around, saw this funky looking document projector thingy on the desk, tossed by laptop under it and away I went. Talk about an icebreaker. There was lots of applause and really great feedback. One attendee even took these pictures.

Here is my slide deck as well, Creating Personalized Documents with a Mashup of Technologies (and some other nifty stuff)

Thanks to Julie Yack for having me. And to Emily Parker and Sasha Krsmanovic at Telerik for sending me.

Time to figure out this projector issue.


Pictures from the 2010 MVP Summit

By James at February 18, 2010 11:35
Filed Under:

Since I am forbidden/prohibited – with good reason – to mention what I learned at the 2010 MVP Summit, I thought, I’d share some pictures

100_0654 100_0656
The view from my room at the Hyatt Looking up at the skylight.
100_0665 100_0670
The *actual* team building MVC. I sat with them during a few presentations on MVC. A building on campus. Notice how I made the clouds go away.
100_0674 100_0676
One of the X-hundred Priuses/i that are used to shuttle people around. Me and Jesse Liberty. What an honor, and a terrific human.
100_0677 100_0678
Me and some guy claiming to be David Silverlight. :) Me and Daron YÖNDEM, a Silverlight MVP from Istanbul Turkey.
100_0680 100_0682
Me and my great friend and fellow IE MVP, Al Pascual. Me and Emily Freet. Emily is in charge of the MVP Program for the “Americas”
100_0683 100_0681
It wouldn’t be a party without my brother Geoff Emery I met with Scott Guthrie too. He said he had heard lots of good things about me and asked me for a meeting the next day…
…this was the result!  



Well, one can dream, can’t they?

Time to party!

A new .NET User Group is born. Say hello to ZamDevs

By James at August 14, 2009 07:22
Filed Under:

One the things I do that really gets me going is finding ways to get people enthused and excited about technology – figuring out what they need, how to get it to them, and then stepping back to see what happens.

Last year, my great friend, Lynn Langit asked if I would be interested in helping to start a new user group. Lynn spends her off time doing volunteer work in Zambia (Africa), and had been working with a small group of developers who wanted to start meeting on a regular basis. So, she put me touch with the leader, Mwansa Lumpa to see what I could do to help.

We talked for a bit via Skype, and I helped him get both a Sitefinity and DiscountASP.NET account setup, and I started collecting swag and books and stuff to send to him.

As the way it is, with busy schedules and such, we kind of lost track of what each of us was doing and how we had been. This morning I received this email.

Subject: ZamDev – The Zambia Developer’s Group

Hi All,

I am really excited as I am writing this email. Great things are and will be happening!!!!

We now have this great opportunity to kick start this group on a high. Its been long over due, and if you are as enthusiastic about having a group that is concerned about your profession as I am, you would have been frustrated by the lack of communication from the group that promises so much - and trust me, we will live up to that.

But now we are back, and we are going to make this a lot more different to all the professional groups that are out there.

So what do we have: Anton Delsink and Lynn Langit - Some of you might have heard these guys speak at Microsoft TechEds( and many other techy events, but now they are here and for free to speak to all of us on some exciting new developments e.t.c. Now thats just the icing on the cake, because the real cake will be the debut of our long awaited group.

When??? on Thursday, the 20th of August 2009. Time: 18:00hrs. Venue: Villa 47. Millenium Village. Long Acres.

We hope to see you there. You will definitely learn a lot and have a great time. Come to the first ever meeting and you will know all about ZamDevs

You are encouraged to invite many many more people to this group! Snacks will be provided, and there will be free give-aways!!!!!!

Mwansa Lumpa

Interim ZamDev Coordinator

PS: You are encouraged to forward this email to your colleagues and workmates.

Way to go Mwansa! Congratulations.

Time to smile,


About the author

James James is a five time and current Microsoft MVP in Client App Development, a Telerik Insider, a past Director on the INETA North America Board, a husband and dad, and has been developing software since the early days of Laser Discs and HyperCard stacks. As the Founder and President of the Inland Empire .NET User's Group, he has fondly watched it grow from a twice-a-month, early Saturday morning group of five in 2003, to a robust and rambunctious gathering of all types and sizes of .NET developers.

James loves to dig deep into the latest cutting edge technologies - sometimes with spectacular disasters - and spread the word about the latest and greatest bits, getting people excited about developing web sites and applications on the .NET platform, and using the best tools for the job. He tries to blog as often as he can, but usually gets distracted by EF, LINQ, MVC, ASP, SQL, XML, and most other types of acronyms. To keep calm James plays a mean Djembe and tries to practice his violin. You can follow him on twitter at @latringo.

And as usual, the comments, suggestions, writings and rants are my own, and really shouldn't reflect the opinions of my employer. That is, unless it really does.

James Twitter Feed

Recent Comments

Comment RSS

Month List