August 27, 2008

A Dynamic Menu For Your Dynamic Data

So I am still playing around with building a Northwind Dynamic Data web site.  Tonight I thought it would be interesting to see what it would take to create a menu for navigating the tables in the site.  I was particularly interested in seeing if I could get some grouping or categorization to the metadata so I could create a multi-leveled menu.  It turns out it wasn't too difficult at all (see the screen shot below - the menu is on the left).  I have my tables organized into 4 categories: Sales, People, Products and Reports.  And the cool thing is that this menu is completely dynamic.  You can add, remove or reorganize the categories without touching the UI.  And depending where you are keeping your metadata you could even do this without recompiling your app.  The grouping is automatically discovered from the metadata and the menu is built solely...

Topics: ASP.NET , Dynamic Data

August 24, 2008

Dynamic Data and Custom Metadata Providers

In my previous post on Dynamic Data, I mentioned that you can use the MetadataType attribute to point Dynamic Data at class that contains additional metadata for your model.  This additional metadata will give you more control over how your UI elements render.  If you don't want a column to display in your GridView, want to change the column header text from EmployeeID to Employee ID or want the cell values formatted a little differently this metadata class is where this information gets specified.  The code snippet below shows how this class can be used for customization. Download 1: // Attach the Employee Metadata to the Employee 2: // entity that the LINQ to SQL designer generates 3: [MetadataType(typeof(EmployeeMetadata))] 4: public partial class Employee 5: { 6: } 7:  8: // Attach some additional metadata 9: public class EmployeeMetadata 10: { 11: // Rename the EmployeeID column to Employee ID...

Topics: ASP.NET , Dynamic Data

August 21, 2008

ASP.NET Dynamic Data - Simple 5 Table Northwind Example

I have been anxiously awaiting the Dynamic Data release.  And now that it is here (it was released with VS 2008 and .Net 3.5 SP1) I decided I would start getting a feel for what is has to offer by building a real simple Dynamic Data web site that allows you to browse the 5 core Northwind tables - Customers, Employees, Orders, Products and Suppliers.  Read on for the details and don't forget to download the code.  DiscountASP hasn't quite upgraded to SP1 so I don't have a live demo setup.  Hopefully they will get the upgrade completed soon, but I made sure to include lots of screen shots so you can get a good idea of what the screens look like.  Download   What is Dynamic Data? I try to keep a close eye on ASP.NET, but I didn't know Dynamic Data was shipping as part of SP1.  I...

Topics: ASP.NET , Dynamic Data

August 18, 2008

IE, Operation aborted and MSDN

Since writing this post on DOM manipulation about a week ago msdn has crashed on me three times with the dreaded operation aborted exception.  Following Dave Reed's comment here, it looks like this is probably occurring because the call to ASP.NET AJAX's client side initialization function is too far away from the forms closing tag - causing the Sys.Application.init event to fire before the DOM is really ready (view source on one of the pages and you will see what I am talking about). Here is an excerpt from Dave's comment: ScriptManager does not put the call to initialize in a “random” location. It is in fact, always the very last thing in the form, just before the closing form tag. There shouldn’t be anything after that (for better or for worse, form is a major part of an asp.net page), and if there is, it could only be because...

Topics: Other

August 14, 2008

Custom Sort Icons with Silverlight 2's DataGrid Control

While looking through the control templates for Silverlight 2's DataGrid, I noticed the DataGridColumnHeader defines a couple of StoryBoards that allow you to control how the headers are displayed as they pass through the three column states: {Sorted Ascending, Sorted Descending, Unsorted}.  And without too much work you can override the default display and customize it to your liking.  I took a crack at overriding these states to mimic the icons the awesome jquery tablesorter plugin uses - below is a sample table that shows how it turned out.  Read on for the details (there really aren't too many) and don't forget to check out the live demo and download. Live Demo | Download   Default Sort Indicator If you look at the default template for the DataGridColumnHeader you will see the control uses a Path shape (named SortIconElement) to describe the sorting icon (the value of the Data attribute...

Topics: Silverlight 2

August 10, 2008

Angled Column Headers with Silverlight 2's DataGrid

At the software shop I work at screen real-estate is always at a premium.  The bread and butter of our business is data, and the more of it we can fit on a screen the happier our customers are.  Sometimes, to cram more data into our grids, we end up abbreviating column headers, wrapping them or possibly combining 2 or 3 data elements into a single cell.  Usually this works out O.K., but sometimes we still run out of room.  When this happens we either remove columns, or break the grid across separate pages.  Honestly, usually none of this is a huge problem.  But there is that certain class of data that just doesn't fit well into an HTML TABLE - when the length of the data elements are substantially smaller than the data label's.  The grid ends up looking too sparse.  I hadn't thought of this before, but football...

Topics: Silverlight 2

August 05, 2008

When is it Safe to Modify the DOM?

This is a pretty important question when in comes to DOM programming.  Start manipulating the DOM to early and bad things happen.  Do it too late and the users may see that annoying flicker.   So what's the best technique for figuring this out?  Well, I was curious about this myself so I took a look at how some of the popular Ajax libraries (jQuery, MooTools, YUI, Prototype and ASP.NET AJAX) are doing this.  Here is what I found out ...   Update: 08/11/2008: I came across an article that sheds more light on ASP.NET AJAX's init technique.  There is a lot of good content in the comments as well (look for the ones left by Dave Reed).  Here are a few snippets of what Dave has to say ... His comments with respect to the location of where the ScriptManager injects the call to Application.initialize ... ScriptManager does not put...

Topics: ASP.NET AJAX , Other , jQuery

July 31, 2008

ASP.NET File Upload with *Real-Time* Progress Bar - redux

So, guess who just got the memo ...   Dear Matt, Uploading large files with ASP.NET is difficult.   Sincerely, Every ASP.NET Developer and their Mother   After sufficiently embarrassing myself with my earlier post, I decided it was high time I spend a little bit more time understanding this problem.  And lo and behold Jon Galloway has already written up a nice survey on the topic.  So to bone up on the issues I followed all of the links Jon provided as well the ones provided by all of the one-off emails I received in response to my previous post (thanks everyone). Of all the upload components I checked-out (SWFUpload, FileUp, Flajaxian FileUploader, RadUpload, NeatUpload, ASP.Net File Upload/Download Module, etc...) I was the most interested in the last 2 (NeatUpload and ASP.Net File Upload/Download Module).  They are both free, have my kind of licensing and come with the full...

Topics: ASP.NET , ASP.NET AJAX

July 27, 2008

A Bloggers Worst Nightmare ...

Four tables in the database that drives my blog was corrupted sometime on Wednesday of last week.  And I did not have a backup.  This is my THS ...   Some Background I use Yahoo! Small Business to host my Moveable Type (MT) blog.  For the past year and a half I have not had any problems at all.  In fact, it worked so well that I did not even know that Moveable Type was storing my entries in a MySQL database.  Looking back, clearly I should have taken the time to understand how MT works, but I didn't really think it was all that important.  I am paying Yahoo! to keep an eye on that stuff - or that's what I thought I was paying for.  I mean check out the second bullet point under Reliable and secure hosting ...    Wednesday, July 23rd I get an email from...

Topics: Other

July 26, 2008

ASP.NET File Upload with *Real-Time* Progress Bar

I had a number of people email me asking how the ProgressBar Toolkit control I blogged about last month could be used to provide progress for file uploads.  So I thought I would spend some time and see how this could be done.  Thankfully, there are a ton of resources available on the internet that discuss this in pretty good detail.  But I didn't see any good examples of how to include the real-time count of the number of bytes that have been transferred.  So I thought I would try to tackle that problem while building my example.   Update 7/27/2008: This post is bogus - I have over simplified the problem.  My goal was to display the number of bytes that have been transferred to the web server, not the number that have been saved to disk.  As atashbahar pointed out, this will require a little bit more work that...

July 17, 2008

My Feedback: ASP.NET AJAX Roadmap

Dave Ward had another great post this past week.  He took the time to not only read the ASP.NET Ajax Road Map document, but he also wrote up a post outlining what he thought about it.  So I thought I would join Dave's efforts and throw in my 2 cents as well.  Of course, most of this post will not make too much sense if you aren't familiar with the Road Map document.  So if that's you, here is what I recommend reading (in order) ... ASP.NET Ajax Road Map The feedback forum Dave's Post: The Future of ASP.NET AJAX (make sure you include the comments) Bertrand Le Roy's post (really only the comments are important)   My Comments ... My goal is to be direct without being rude, lets see if I can do it.    $query Any plans on providing an extensible selector engine?  If you have to...

July 15, 2008

jQuery.UI ProgressBar Widget

I don't know squat about building widgets with jQuery, so I thought I would fix this by rearranging my trusty progress bar code once more and see how it would look as a jQuery.ui widget.  The jQuery.ui documentation is still a work in progress so it was a bit of an adventure, but once again the elegance of jQuery kept my frustrations to a minimum and I think I ended up with something pretty useful.  Read on if you are interested in the details and don't forget to check out the demo page (progress bar's don't show so well as static images). Live Demo | Download | ui.progressbar.js   What is jQuery.ui? Assuming you aren't real familiar with jQuery.ui (I certainly wasn't until yesterday), here is a quick overview ... jQuery UI provides abstractions for low-level interaction and high-level, themeable widgets, built on top of the jQuery JavaScript Library, that...

Topics: jQuery

July 10, 2008

On Candor

"Thanks for being so candid" Ughh - I hate that phrase more than any other.  I hate it because it means the discussion is over and the other person has taken the easy way out of the conversation.  In case you are unfamiliar with the phrase, here are some sample usages ... Me: We need a dedicated QA staff. They: Thanks for being so candid, but blah blah blah.   Me: We need something that at least resembles requirements. They: Thanks for being so candid, but blah blah blah.   Me: Defect-free software is an unrealistic goal. They: Thanks for being so candid, but blah blah blah.   And I think its funny that people think it is a compliment.  Of course I am going to provide candid opinions - its much harder to try and lie....

Topics: Other

July 09, 2008

How I Got Started in Programming

Dave tagged me in Michael Eaton's software development meme that's being floating around.  So here we go ...    How old were you when you started programming? About 20.  I know most folks started at a much younger age but I didn't get into programming until I went off to college.  Before that I just used computers to play video games.  Choplifter for the Apple II is the first one that I can remember, but id software's Doom is the one I obsessed over.  With a weapons like the BFG and Chainsaw what's not to love?   How did you get started in programming? My wife Katie (girlfriend at the time) made me.  I was just entering my third year in college and my major was university studies.  At that point college really wasn't going too well for me.  I failed an entry level Trig class (no joke, I went the...

Topics: Other

June 29, 2008

Using jQuery Plugins with ASP.NET

The controls found in the AjaxControlToolkit fit perfectly into the ASP.NET programming model (as to be expected).  You can configure the controls properties through the markup which in turn affects how the control's display and behavior on the client.  Many of the control's properties support databinding so using the controls within a databound control like a ListView or a GridView is no big deal.  Take for example the ProgressBar Toolkit control I blogged about (here and here).  One of the places that I use this control is in a GridView's TemplateField.  Instead of displaying the percentage as a text value, I use the ProgressBar to display the percentage in a more visual manner.  It looks something like this ... Live Demo | Download With the Toolkit, setting this up is really simple.  Just use a databinding expression to set the Value property of the ProgressBar control to the value of...

June 26, 2008

glowbuttons - Writing My First jQuery Plugin

So I figure what better way to learn more about jQuery than to dig right in and create a plugin or two?  At first I thought this sounded pretty intimidating, but after browsing through some of the existing jQuery plugins I figured it might be easy enough to try and 'rearrange' one of the Toolkit controls that I created.  So that is what I did with my GlowButtonExtender control I created a few months back (and I plan on doing it with the ProgressBar one as well very soon).  I kind of liked this because I thought creating the same UI widget using both the Toolkit and jQuery might give a little more insight into what the relative advantages are between the two frameworks. In case you didn't see my original post on creating the GlowButtonExtender control, here is how it works:  When you mouse over the button, it glows...

June 23, 2008

AjaxControlToolkit Script Browser

When creating my last post I tracked down all of the JavaScript files the ModalPopup Toolkit control loads.  I did this manually by using FireBug to see what script files were pushed out to the client and then I used Reflector to find out the size of the file (the Toolkit embeds the JavaScript files as resources).  That was tedious.  But I found the information pretty useful (I wouldn't have guessed the ModalPopup required the RoundedCorners script) and so I thought it might be useful to view this information for all of the Toolkit controls. So I cooked up a simple console application that rips through the Toolkit's assembly (I used version 1.0.20229.0) and tracks down all of the ClientScriptResources a particular control is using.  As I identified the scripts I ran then each through the minify -> gzip process so I could better gauge how large these scripts are...

June 22, 2008

Master-Detail with the GridView, DetailsView and jQuery's ThickBox

And so I continue on messing around with jQuery and looking into ways I can use it in my WebForms applications.  Something I sheepishly admitted to in my last post was that I don't want to use 3 client side libraries {ASP.NET AJAX, AjaxControlToolkit, jQuery}, yet I never really took the time to see what the size of the core jQuery library is.  And for that matter I haven't really looked at what scripts some of my favorite AjaxControlToolkit controls are pulling down either.  I also assumed there is a bunch of overlap between jQuery and ASP.NET AJAX, but I haven't looked into that either.  So I thought I would check some of this out and along the way rebuild my Master-Detail with the GridView, DetailView and ModalPopup Controls and replace the ModalPopup with jQuery's ThickBox.  I found it pretty interesting - read on to see how it went.Live Demo...

June 17, 2008

Getting jQuery Goodness into ASP.NET AJAX - Take II

So clearly I am obsessing about getting jQuery features into my WebForm applications.  I would seriously love to see the following added ... A more powerful selector.  Finding elements by ID (ala $get) in an ASP.NET page is usually pretty awkward because the ID values isn't known until runtime.  This alone causes many people problems.  Unless I am mistaken the next version of ASP.NET AJAX will include a selector to find items by class name as well, but I have not heard anything for supporting more advanced stuff like ... 1: // good ... 2: var alternatingRows = $select('TABLE TR.alt'); 3:  4: // better ... 5: var alternatingRows = $select('TABLE TR:odd'); 6:  7: // best! 8: var alternatingRows = $select('TABLE TR:nth-child(odd)');   A more fluent programming model.  jQuery seriously embraces the 'find some elements and do something with them' mantra.  And they make it really simple to do - if...

June 15, 2008

Getting jQuery Goodness into ASP.NET AJAX

If you have been following along with me over the past few days you have seen that I am looking into ways to incorporate some of the goodness of jQuery into ASP.NET AJAX.  Of course the obvious question is why don't I just switch over to jQuery completely?  Well ... The team I work on is not switching from WebForms to MVC any time soon. And I am fine with that - we have a bunch of good dev's all with plenty of years of WebForms experience so we understand all of the quirks and can get past any of the weirdness that sometimes pops up. But I don't really want to use 3 ajax libraries (jQuery, ASP.NET AJAX and the Toolkit). But I like how easy it is to author and distribute jQuery plugins and I wish there was a similar pattern for ASP.NET AJAX. I posted that bit...


Sponsor

Recent Comments

  • Mark Beachill wrote: Great post - this is of course how almost every database is written, it is rare that people put spac...
  • Justin Moses wrote: Matt, your tutorials are amazing. That said, you should include the updates to this in the project ...
  • Michael Paladino wrote: Thanks again. You've provided another solution for me. Thanks also to those commenters that provid...
  • César wrote: Matt: (I speak very very few english.) Good sample. Help me please. I need convert MailBoxItems.c...
  • Ruchit Surati wrote: Hi Matt, I'm calculating the GridView column data for each row dynamically in code-behind. How do I...
  • Jacques wrote: Please note the difference between the documentation and Matt's ServiceMethod: Matt's ...
  • Gustavo Muller wrote: Nice work ! Actually I'm using some parts of your styles in order to improve aparience. Now I'm h...
  • laptop ac adapter wrote: the data source does not support sorting with IEnumerable data. Automatic sorting is only supported ...

Sponsor