Tuesday, December 22, 2009

UpdatePanel won't AsycPostback for anything.

I spent a lot of time today and Friday trying to get my UpdatePanel to be handled properly. No matter what I did, my asynchronous triggers were only posting back. I searched and searched, and couldn't find anything. Then, I ran across a post on asp.net's forum which had the answer.
<xhtmlConformance mode="Legacy"/> :
Change Legacy to Strict or Transitional
Don't you love Microsoft?
Other things I searched for in order to find this answer:
"IsInAsyncPostBack false masterpage", "UpdatePanel only postback", "asp:AsyncPostBackTrigger won't work"

Sunday, December 20, 2009

Google Chrome Extension: New Tab Redirect!

Thanks to the blizzard this weekend, I've been alone and stuck inside long enough to write an extension for Google Chrome. It's called "New Tab Redirect!" and it allows you to customize the page displayed when you add a new tab (either with CTRL+T or clicking the (+) in the title bar).

A cool thing about the extension is that it allows you to specify about: pages, URLs, or local files.

The extension is available in the extension Gallery: http://bit.ly/info/8oNcya

Thursday, December 17, 2009

jQuery check/uncheck all Checkboxes in ASP.NET

For some odd reason, ASP.NET GridView wraps html elements in a span element. When you apply a CssClass to the asp:CheckBox for instance, you will have a span with that class and inside you'll have an input with type=checkbox.
So how do you access all of the checkboxes?

   1:              $('.chkAllSelector > input:checkbox').click(function() {
   2:                  $('.chkRowSelector > input:checkbox').each(
   3:                      function(){
   4:                          this.checked = $('.chkAllSelector > input:checkbox').attr('checked');
   5:                      }
   6:                  );
   7:              });
   8:              $('.chkRowSelector > input:checkbox').click(function() {
   9:              if ($('.chkAllSelector > input:checkbox').is(':checked') && !($(this).is(':checked')))
  10:                  { $('.chkAllSelector > input:checkbox').removeAttr('checked'); }
  11:              });

Wednesday, December 16, 2009

Extending IDataReader

I like to access my DataReader objects via column name. Unfortunately, IDataReader supports getting items via integer indexer.

To overcome this *obstacle*, I've written an extension method I'd like to share. It checks to see whether a column exists and has a value associated with it.

   1:      public static class IDataReaderExtension
   2:      {
   3:          /// <summary>
   4:          /// Adds the HasValue property to an IDataReader, which checks based on Column name
   5:          /// </summary>
   6:          /// <param name="reader">An IDataReader object</param>
   7:          /// <param name="column">The string column name</param>
   8:          /// <returns>boolean</returns>
   9:          public static bool HasValue(this IDataReader reader, string column)
  10:          {
  11:              if (reader.GetSchemaTable().Columns.Contains(column))
  12:                  return reader[column] != null || reader[column] != DBNull.Value;
  13:              else
  14:                  return false;
  15:          }
  16:      }

In order to use this method, you can now check:

   1:  if(reader.HasValue("MY_COLUMN"))
   2:  {
   3:      myObject.ColumnInfo = Convert.ToString(reader["MY_COLUMN"]);
   4:  }

Archive