Posts

Showing posts from September, 2008

Mutual Exclusive CollapsiblePanelExtender

The following piece of code will allow you to have multiple ASP.NET 2.0 Ajax CollapsiblePanelExtender controls on a single page and only one of them will be expanded at a time. You can use this to keep the page length short. You must set the BehaviorId of the CollapsiblePanelExtender, that is what the $find javascript function looks for. Make sure to add all the BehaviorIds to the array in the pageLoad function. <script type= "text/javascript" > // WWB: Handles Mutual Exclusive Expansion. Only One Extender Panel // Can Be Open At A Time var extenders = []; function pageLoad(sender, args) { extenders[0] = $find( "PanelExtender1" ); extenders[1] = $find( "PanelExtender2" ); extenders[2] = $find( "PanelExtender3" ); // WWB: Hook All The Extenders, If extenders[i] is null then // the extenders is not being displayed -- i.e. not visible for (var i=0; i< extenders.length; i++) if (extenders[i] !

Happier Coding

Dina says I am happier when I code and not just during coding. Some of my friends my age, and yes I am getting older, are moving to management jobs where they don’t code at all. They might be development leads that train and deploy new technologies in bigger companies, or design systems and have others code. Some of the same friends that interviewed at our smaller company and we didn’t hire because they just didn’t seem right (Where I work now you can’t just design or train since the company is so small). These friends fit right in with the bigger companies; in fact they got jobs as developers however aren’t really doing any development at all. I have a hard time calling these jobs management since they don’t have a lot of people under them; I really just want to call them a “Non-Productive” job – which is reflection of my perspective on how I like coding. I wonder if the bigger companies will “wake up” and make them do something, or force them to do development which they were hir

Indoubt Transaction in MSDTC

Image
For days I have been battling with MSDTC (Microsoft Distributed Transaction Server) and transaction that have the status of indoubt.  We are using the .NET System.Transactions.TransactionScope class to wrap many SQL Server calls together in a single transaction, which requires MSDTC to manage the transaction.  The application would run for 30 minutes then hang, timing out, and the table on SQL Server would end up being row locked -- hanging all selects, inserts, updates and deletes.  It took me a while to realize that the Kerbose error in the application log on SQL Server was the reason the MSDTC communication was failing -- by comparing the crash time with the error log.  Then doing some research I realized that all those virtual machines running our web servers that we copied around on our virtual servers had the same SID.  Even though we had renamed them and readded them to the domain, that didn't generate a new SID.  So I used Microsoft's NewSID utility to give them differe

DataBind() on Postback

Image
Please junior developers don't Databind() your GridView on Postback.  You only need to databind your GridView once, when the page is first loaded (and anytime the data changes).  However, if you are lazy then you will DataBind on every postback forcing the GridView to go to the data source every postback and making your page slow.  Your junior code: protected void Page_Load( object sender, EventArgs e) {     ERSGridView1.DataBind(); } My code: protected void Page_Load( object sender, EventArgs e) {      if (!Page.IsPostBack)         ERSGridView1.DataBind(); } But, But... Yes DataItem will not be accessible on Postback, so this code will not work: protected void ERSGridView1_SelectedIndexChanged( object sender, EventArgs e) { object myData = ERSGridView1.SelectedRow.DataItem; } You will have to do this: protected void ERSGridView1_SelectedIndexChanged( object sender, EventArgs e) {    Int32 primaryKey = (Int32)ERSGridView1.DataKeys[ERSGridView1.SelectedIndex].V

RaisePostBackEvent and RegisterRequiresRaiseEvent

Image
ASP.NET 2.0 You do not have to call Page.RegisterRequiresRaiseEvent() in order for IPostBackEventHandler.RaisePostBackEvent() event to be called. In fact calling Page.RegisterRequiresRaiseEvent() will interfer with all other controls on the page that need post back events. The only way calling Page.RegisterRequiresRaiseEvent() actually works is if that is the only control on the page. GridView doesn't have to call Page.RegisterRequiresRaiseEvent(). However, implementing just IPostBackEventHandler isn't good enough, you need to implement: IPostBackDataHandler also on your control. If you don't then IPostBackEventHandler.RaisePostBackEvent() will never be called. {6230289B-5BEE-409e-932A-2F01FA407A92}

/useenv on the command line.

Image
/useenv as s command line switch in Visual Studio 2005 is described as: "Use the following command line switches to display the integrated development environment and perform the described task." as opposed to: "Use the following command line switches to perform the described task. These command line switches do not display the IDE."  Reference: http://msdn.microsoft.com/en-us/library/xee0c8y7(VS.80).aspx   Which would make you think that /useenv is a switch for the IDE, however if you don't use it on the command line your settings for INCLUDE and LIB enviormental variables will not be used, making it very difficult to switch between platform SDK include files for your different OS versions. {6230289B-5BEE-409e-932A-2F01FA407A92}  

Warning As Error CS1668 -- Not the Usually Excuse

You can get CS1668 if you set your LIB path like this in your .bat file that builds your project using devenv.exe: SET LIB="c:\Program Files\Microsoft SDKs\Windows\v6.0\Lib\" instead of like this (the right way): SET LIB=c:\Program Files\Microsoft SDKs\Windows\v6.0\Lib\ Note the quotes. Time Wasted: 2 hours. The usual suspect: http://msdn.microsoft.com/en-us/library/tcbs315h(VS.80).aspx {6230289B-5BEE-409e-932A-2F01FA407A92}

Google Chrome And IIS 5.0

Image
Don't get me wrong, I like Google Chrome, and it's application shortcut that makes a web application appear like a windows application is an eye opener.  However, it reminds me of IIS 5.0.  When IIS 5.0 was released everyone was so excited that you could run the web site application in a separate process, giving you one process per web site.  This meant if a web site crashed it wouldn't take down the rest of the sites on the server.  However, it was soon realized that windows can only handle a finite amount of threads somewhere between 500 - 800 before it slows to a crawl.  This is why you need to be very careful when multi-threading. All the IIS 5.0 web sites with 5-10 threads a piece where chocking the OS.   So IIS 5.0 was replaced with IIS 6.0 where you could group web sites into a single process.  Back to Chrome: 26 threads just to run Pandora.com in one process.  The other processes are running 9 threads a piece.  Just for you that don't know, each tab in Chrome ru

Mapping in SQL Server Reporting Services

n honor of William Vaugh showing up at our local .NET user group, I am posting a SSRS article about how to add maps to your SQL Server Reporting Service reports. Google Map has static mapping functionality in their API set. Static maps are the ability to call a URL on the Google server and get back a single image of the map. This is different then using the Ajax objects in your web page, since those objects need the javascript engine to excute. With SSRS you don't get a javascript engine and you can't be guareenteed that it will be a web page, the export might be a PDF. Google Maps API for static maps takes a Query string like this example: http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile\&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc\&key=MAPS_API_KEY With good eyes you can see that it sets the center, zoom, and some markets on the map. First thing to do is dro