Posts

Showing posts with the label jQuery

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 re...

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...

Cascading DropDowns w/ JQuery ViewState Problem - use the UpdatePanel w/ triggers instead

I spent a lot of time trying to resolve a DOM issue I was having with a cascading drop downs setup on my page.  After mucking around with it for quite a while, I was able to figure out that it wasn't a direct effect of my code, but seemed to be a result of some DOM corruption that was happening from a plugin I was using or something else (that would be very time consuming to uncover). I was making a web service (POST) call to update the 2nd drop down list... if ($(someDDObject).val().length > 0) { someGlobalVariable = $(someDDObject).val(); ExecuteCallback('DoneChanged|' + someGlobalVariable); } The ExecuteCallBack is tied to a server-side async, non-static function that would parse the input and return the updates. A nice clean way to get server-side data without a postback, right? Right...mostly. The problem came in trying to update the client side data. In the callback function on the client, I would process the data like so: function CallBackResul...