Posts

Showing posts from July, 2010

The hidden workings of __doPostBack - Full or Partial Postback?

In experimenting with how I could manually create a partial postback, I ran into some odd behavior.  I was using the old '__doPostBack('target', 'argument')' javascript call to perform the post back and that was all well and good, but I noticed that my page was doing a full post back instead of a partial each time. After digging around for a bit (where would software development be w/o Google search?), I found this tidbit here (I'm always grateful when others have spent a few hours finding little programming nuggets to share - less time searching for me): __doPostBack starts by trying to retrieve an element in the client DOM with the corresponding ClientID to the UniqueID you pass as the first argument to __doPostBack. (it translates the UniqueID to a ClientID by replacing the "$"s in the UniqueID with "_"s) If it finds a corresponding client element, it searches up the DOM for a parent that has the same id as an updatepanel (it kee

Unobtrusively change/wrap the onclick event handler in jQuery

In designing a user control that does quite a bit of UI manipulation to an ASP.NET page on the client-side of things, I ran into a bit of trouble in using a 'wrapper' onclick handler for a GridView row onclick event.  I will be putting this user control on many pages and did not want to couple the control to the page, or at least I wanted to minimize that coupling as much as possible. Ultimately, I was left with two choices:  manually change the server-side injected javascript for the row's onclick event on every page, or find a way to do it in the user control.  The user control uses the jQuery library, so I was in luck.  When I say I want it to be unobtrusive, I mean I want to execute whatever code the row's event handler has been coded to execute, but under the inspection of my user control (i.e. - to only do so conditionally). My user control injects a new column into the GridView when a certain mode is introduced, which column is purely independent of the rest

Quick rendering of modified ASP.NET GridView w/ some jQuery magic

I came across a powerful performance saver using jquery while adding a column to an Asp.Net GridView client-side.  Put very simply, when creating the columns (including the header), set the display to "none".  Group the new header column and each new row's column with a special css class (like "somethingfunkythiswaycomes"). When all the rows have been changed (at the end of your .each jquery loop), simple call: $(".somethingfunkythiswaycomes").show(); In firefox and chrome, the rendering is very fast and the whole action is at least as fast as a partial postback, w/o any annoying flicker. NOTE :  In IE (which continues to stand tall as the world's worst browser - maybe IE 9 will change my mind...), this technique does NOT work.  When I tried to use this on a 1000 row result set, it took 20 minutes to re-render.  20 freakin' minutes!?  Are you insane??  In Firefox 3 and Chrome 4, it took maybe 2 - 3 seconds! Could be another case of Mi