<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6713504098021786998</id><updated>2011-11-28T05:53:20.252+05:30</updated><category term='Hyperlink Column'/><category term='IE7'/><category term='ClearType text'/><category term='XSLT'/><category term='XSL'/><category term='sp_rename'/><category term='XSLCustomFunctions'/><category term='.NET 2.0'/><category term='Renaming Column'/><category term='Exception Handling'/><category term='GridView'/><category term='SQL Server'/><title type='text'>My Tech Turf</title><subtitle type='html'>Technical Blog on Microsoft Technologies mainly .NET and SQL Server</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tech-turf.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://tech-turf.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Mayank</name><uri>http://www.blogger.com/profile/01711884180204765247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6713504098021786998.post-4775471623994715709</id><published>2007-10-25T12:39:00.000+05:30</published><updated>2007-10-25T12:41:35.381+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Exception Handling'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Exception Handling in SQL Server 2000 and 2005</title><content type='html'>&lt;span style="font-family:verdana;font-size:85%;"&gt;Till the era of SQL Server 2000, there was no standard and structured way of exception handling in procedures return in SQL. Developers have to use the standard error variable “@@ERROR” to check if any error has occurred and take the necessary action.&lt;br /&gt;&lt;br /&gt;A sample code in SQL Server 2000 will look like this:-&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:courier new;color:#660000;"&gt;BEGIN TRANSACTION&lt;br /&gt;&lt;br /&gt;--Write your statements here like “insert into some table”&lt;br /&gt;&lt;br /&gt;set @Error = @@ERROR&lt;br /&gt;&lt;br /&gt;--if there is some error&lt;br /&gt;&lt;br /&gt;if @Error &lt;&gt; 0&lt;br /&gt;Begin&lt;br /&gt;      ROLLBACK TRANSACTION&lt;br /&gt;Else&lt;br /&gt;      COMMIT TRANSACTION&lt;br /&gt;End&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;SQL Server 2005 have come with Try-Catch blocks, very similar to those used in frontline programming languages like C# and Java. Hence the same code above can be written in a much structured and efficient way in SQL Server 2005 as follows :-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;color:#660000;"&gt;&lt;strong&gt;BeginTry&lt;br /&gt;       BEGIN TRANSACTION&lt;br /&gt;       -- Do some operations here like “insert into some table”&lt;br /&gt;       COMMIT TRANSACTION&lt;br /&gt;EndTry&lt;br /&gt;BeginCatch&lt;br /&gt;      ROLLBACK TRANSACTION&lt;br /&gt;EndCatch&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;Notice the important keywords here – “BeginTry”, “EndTry”, “BeginCatch” and “EndCatch”. These are equivalent of “Try-Catch” blocks used in C# or Java.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;&lt;strong&gt;&lt;em&gt;~Mayank&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6713504098021786998-4775471623994715709?l=tech-turf.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-turf.blogspot.com/feeds/4775471623994715709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6713504098021786998&amp;postID=4775471623994715709' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/4775471623994715709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/4775471623994715709'/><link rel='alternate' type='text/html' href='http://tech-turf.blogspot.com/2007/10/exception-handling-in-sql-server-2000.html' title='Exception Handling in SQL Server 2000 and 2005'/><author><name>Mayank</name><uri>http://www.blogger.com/profile/01711884180204765247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6713504098021786998.post-3839905412720435803</id><published>2007-10-15T16:22:00.000+05:30</published><updated>2007-10-15T16:41:39.812+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hyperlink Column'/><category scheme='http://www.blogger.com/atom/ns#' term='GridView'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET 2.0'/><title type='text'>Passing two arguments in DataNavigateUrlFormatString in hyperlink field of .NET 2.0 Grid-View</title><content type='html'>&lt;span style="font-family:verdana;font-size:85%;"&gt;In a hyperlink column of gridview, suppose the value of the property &lt;strong&gt;DataNavigateUrlFormatString&lt;/strong&gt; is “&lt;span style="font-family:courier new;"&gt;ProductsForSupplierDetails.aspx?SupplierID={0}&lt;/span&gt;”. Many people think that the argument {0} is replaced by the value of the property &lt;strong&gt;DataKeyNames&lt;/strong&gt; of the Gridview. But in actual case this is replaced by the value of the property &lt;strong&gt;DataNavigateUrlFields&lt;/strong&gt; of the hyperlink column.&lt;br /&gt;&lt;br /&gt;Now suppose you want to pass two arguments instead of one, something like this “&lt;span style="font-family:courier new;"&gt;ProductsForSupplierDetails.aspx?SupplierID={0}&amp;amp;CompanyName={1}&lt;/span&gt;”.&lt;br /&gt;&lt;br /&gt;Now as these two arguments come from property &lt;strong&gt;DataNavigateUrlFields&lt;/strong&gt; of the hyperlink column. So value of this property has to be “&lt;span style="font-family:courier new;"&gt;DataNavigateUrlFields="SupplierID,CompanyName&lt;/span&gt;”.&lt;br /&gt;&lt;br /&gt;At run time the .NET replaces {0} with “SupplierID” and {1} with “CompanyName” of that row.&lt;br /&gt;&lt;br /&gt;&lt;asp:boundfield sortexpression="SupplierID" readonly="True" insertvisible="False" headertext="SupplierID" datafield="SupplierID"&gt;&lt;asp:boundfield sortexpression="CompanyName" headertext="CompanyName" datafield="CompanyName"&gt;&lt;asp:boundfield sortexpression="Address" headertext="Address" datafield="Address"&gt;&lt;asp:boundfield sortexpression="City" headertext="City" datafield="City"&gt;&lt;asp:boundfield sortexpression="Country" headertext="Country" datafield="Country"&gt;&lt;asp:boundfield sortexpression="Phone" headertext="Phone" datafield="Phone"&gt;&lt;asp:hyperlinkfield text="View Products" datanavigateurlformatstring="ProductsForSupplierDetails.aspx?SupplierID={0}&amp;amp;CompanyName={1}" datanavigateurlfields="SupplierID,CompanyName"&gt;Pretty simple and straightforward it seems but I have seen many people struggling with this simple concept. Also I found wrong answers for this problem in some .NET forums. Hence thought to post it here for benefit of masses.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;&lt;strong&gt;&lt;em&gt;~Mayank&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/asp:hyperlinkfield&gt;&lt;/asp:boundfield&gt;&lt;/asp:boundfield&gt;&lt;/asp:boundfield&gt;&lt;/asp:boundfield&gt;&lt;/asp:boundfield&gt;&lt;/asp:boundfield&gt;&lt;br /&gt;&lt;?xml:namespace prefix = asp /&gt;&lt;asp:boundfield sortexpression="SupplierID" readonly="True" insertvisible="False" headertext="SupplierID" datafield="SupplierID"&gt;&lt;asp:boundfield sortexpression="CompanyName" headertext="CompanyName" datafield="CompanyName"&gt;&lt;asp:boundfield sortexpression="Address" headertext="Address" datafield="Address"&gt;&lt;asp:boundfield sortexpression="City" headertext="City" datafield="City"&gt;&lt;asp:boundfield sortexpression="Country" headertext="Country" datafield="Country"&gt;&lt;asp:boundfield sortexpression="Phone" headertext="Phone" datafield="Phone"&gt;&lt;asp:hyperlinkfield text="View Products" datanavigateurlformatstring="ProductsForSupplierDetails.aspx?SupplierID={0}&amp;amp;CompanyName={1}" datanavigateurlfields="SupplierID,CompanyName"&gt;&lt;/asp:hyperlinkfield&gt;&lt;/asp:boundfield&gt;&lt;/asp:boundfield&gt;&lt;/asp:boundfield&gt;&lt;/asp:boundfield&gt;&lt;/asp:boundfield&gt;&lt;/asp:boundfield&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6713504098021786998-3839905412720435803?l=tech-turf.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-turf.blogspot.com/feeds/3839905412720435803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6713504098021786998&amp;postID=3839905412720435803' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/3839905412720435803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/3839905412720435803'/><link rel='alternate' type='text/html' href='http://tech-turf.blogspot.com/2007/10/passing-two-arguments-in.html' title='Passing two arguments in DataNavigateUrlFormatString in hyperlink field of .NET 2.0 Grid-View'/><author><name>Mayank</name><uri>http://www.blogger.com/profile/01711884180204765247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6713504098021786998.post-3691939277331911819</id><published>2007-10-15T10:18:00.000+05:30</published><updated>2007-10-15T10:30:26.885+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='sp_rename'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Renaming Column'/><title type='text'>Renaming table column name in SQL Server</title><content type='html'>&lt;p  style="text-align: justify;font-family:verdana;" class="MsoNormal"&gt;&lt;span style="font-size:85%;"&gt;Well, that’s a pretty simple requirement if you are a database developer. Surprisingly I was only aware of how to do this using SQL Server Enterprise Manager. But one of my friends asked me how to do it using SQL Script. The requirement was that we cannot drop the existing table and recreate it again as the table has a lot of data. A little googling helped to figure out that it’s pretty simple. &lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;    &lt;/div&gt;&lt;p  style="text-align: justify;font-family:verdana;" class="MsoNormal"&gt;&lt;span style="font-size:85%;"&gt;There is an inbuilt system stored procedure “sp_rename” which can be used to accomplish this task. Infact this system stored procedure can be used to rename a user created object like table, column or user-defined data-type. &lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;    &lt;/div&gt;&lt;p  style="text-align: justify;font-family:verdana;" class="MsoNormal"&gt;&lt;span style="font-size:85%;"&gt;The syntax is pretty simple:-&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p  style="text-align: left;font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;sp_rename&lt;/b&gt; [ &lt;b&gt;@objname = &lt;/b&gt;] &lt;b&gt;'&lt;/b&gt;&lt;i&gt;object_name&lt;/i&gt;&lt;b&gt;' ,     &lt;/b&gt;[ &lt;b&gt;@newname = &lt;/b&gt;] &lt;b&gt;'&lt;/b&gt;&lt;i&gt;new_name&lt;/i&gt;&lt;b&gt;'&lt;/b&gt;&lt;b&gt;, &lt;/b&gt;[ &lt;b&gt;@objtype = &lt;/b&gt;] &lt;b&gt;'&lt;/b&gt;&lt;i&gt;object_type&lt;/i&gt;&lt;b&gt;' &lt;/b&gt;]&lt;/span&gt;     [ &lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p  style="text-align: justify;font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;Eg. - To rename a column of table – “MyTable” from “OldColumnName” to “NewColumnName”, use following syntax:-&lt;/span&gt;&lt;/p&gt;&lt;p  style="text-align: left;font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold; color: rgb(102, 0, 0);font-family:courier new;" &gt;EXEC sp_rename 'MyTable.[OldColumnName]', 'NewColumnName', 'COLUMN'&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="text-align: justify;font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;And yes, that’s it. Pretty simple, but then you need to know it that something like this exists. :)&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p  style="font-weight: bold; font-style: italic; text-align: justify;font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;~Mayank&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6713504098021786998-3691939277331911819?l=tech-turf.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-turf.blogspot.com/feeds/3691939277331911819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6713504098021786998&amp;postID=3691939277331911819' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/3691939277331911819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/3691939277331911819'/><link rel='alternate' type='text/html' href='http://tech-turf.blogspot.com/2007/10/renaming-table-column-name-in-sql.html' title='Renaming table column name in SQL Server'/><author><name>Mayank</name><uri>http://www.blogger.com/profile/01711884180204765247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6713504098021786998.post-6852858970149337718</id><published>2007-09-25T11:28:00.001+05:30</published><updated>2007-09-25T15:39:18.148+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='ClearType text'/><category scheme='http://www.blogger.com/atom/ns#' term='IE7'/><title type='text'>ClearType Text</title><content type='html'>&lt;div align="justify"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;Two days back, I installed IE 7 on my PC. After installing it, I found a visible change in the fonts in both IE and Outlook. And as usual, change is always uncomfortable. The fonts were coming more of blurred type and not very clear. After struggling with these new font styles, I finally googled for the problem and came out across a blog by Microsoft’s IE 7 project manager, which mentions what the new font style is all about.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/ie/archive/2006/02/03/524367.aspx"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;http://blogs.msdn.com/ie/archive/2006/02/03/524367.aspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;&lt;br /&gt;Basically IE7 has come up with concept of “ClearType” text which makes text more readable and comprehensible to human eyes. It is especially useful for LCD monitors rather than old CRT monitors. But as Microsoft tries to dictate terms always, so they enable this in IE7 by default without even asking the user about it or telling how to turn if ON-OFF. Thankfully, the option is there to turn it off by using Tools &gt; Internet Options &gt; Multimedia &gt; Uncheck “Always use clear-type for HTML”. Once this is done and IE is restarted (very imp.), we return back to our good old fonts.&lt;br /&gt;&lt;br /&gt;Coming back to ClearType text technology, this has been introduced in Office 2007 and Windows Vista by default. So whenever you install these softwares on your PC, these are enabled by default. I am yet to figure out how to turn them off. Presently I am using windows XP where ClearType text is turned off by default. We can turn it ON by changing some windows registry settings but that is always dangerous. A little more googling lead me to following link:-&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.microsoft.com/typography/ClearTypePowerToy.mspx"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;http://www.microsoft.com/typography/ClearTypePowerToy.mspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;This is a downloadable utility which can be installed on your PC and then it appears in Control Panel. Using this you can turn on “ClearType” on your XP PC and also choose the setting and font contrast which you find most comfortable.&lt;br /&gt;&lt;br /&gt;In the end, all these things are dependent on individual perception. Some people may like it, some may not. I am trying to adjust my eyes for this new font style from last two days and I have pretty much succeeded in that. Though fonts look slightly blurry in this style but their readability has definitely improved. I am able to concentrate better while reading documents and web-pages.&lt;br /&gt;&lt;br /&gt;To Summarize, its individual perception and comfort level to change that matters. But I recommend giving it a try atleast once. If you are not satisfied, you always have the option to turn it off. :)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="font-family:georgia;"&gt;~Mayank&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6713504098021786998-6852858970149337718?l=tech-turf.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-turf.blogspot.com/feeds/6852858970149337718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6713504098021786998&amp;postID=6852858970149337718' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/6852858970149337718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/6852858970149337718'/><link rel='alternate' type='text/html' href='http://tech-turf.blogspot.com/2007/09/cleartype-text.html' title='ClearType Text'/><author><name>Mayank</name><uri>http://www.blogger.com/profile/01711884180204765247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6713504098021786998.post-7744237703674395386</id><published>2007-07-25T15:43:00.000+05:30</published><updated>2007-07-25T15:47:11.998+05:30</updated><title type='text'>Creating Hourglass cursor in Web-Applications</title><content type='html'>&lt;div align="justify"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;Very often, in most of the windows application, there is a functionality in which the mouse cursor changes to hour-glass whenever the application is doing some background processing or is busy. This is done to give user an intimation to wait for application to finish processing.&lt;br /&gt;&lt;br /&gt;We had a similar requirement in one of our web-applications. In the application, the mouser cursor has to be changed to hour-glass when user clicks on a particular button or whenever post-back happens. The cursor has to return back to normal as soon as the processing of the page finishes.&lt;br /&gt;&lt;br /&gt;We achieved this functionality using JavaScript and HTML.&lt;br /&gt;&lt;br /&gt;For this first we write a JavaScript function which changes the mouse cursor to hour-glass.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;color:#660000;"&gt;function ChangeToHourGlass()&lt;br /&gt;{&lt;br /&gt;document.body.style.cursor = 'wait';&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now we need to call this function appropriately so that the required effect is achieved. So we call this function in two page events – &lt;strong&gt;onbeforeunload&lt;/strong&gt; and &lt;strong&gt;onunload&lt;/strong&gt;. This is done by adding these events handlers in the “body” tag of your ASPX/HTML page.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;color:#660000;"&gt;&amp;lt;body onbeforeunload="ChangeToHourGlass();" onunload="ChangeToHourGlass ();"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now let’s explain in short about both these event handlers:-&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Onbeforeunload&lt;/strong&gt; – This event is fired before a page is getting unloaded.&lt;br /&gt;&lt;strong&gt;OnUnload&lt;/strong&gt; – This event is fired just before the page is getting unloaded.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How the actual functionality works:-&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;When we click on a submit button in a page, the current page is unloaded. So one of these events is fired and the mouse cursor changes to hour-glass. While the request goes to back-end and returns back with the result, the current page continues to display. So mouse cursor appears as hour-glass. As soon as the back-end processing is finished, the page is re-created in which the mouse cursor returns back to normal. Hence the desired functionality is achieved.&lt;br /&gt;&lt;br /&gt;The reason for using both these event handlers is that Internet Explorer browser prefers “Onbeforeunload” event while other browsers prefer “OnUnload” event. So to make this functionality work in all types of browsers, the JavaScript function is called in both these events.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:georgia;font-size:85%;"&gt;&lt;strong&gt;&lt;em&gt;~Mayank&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6713504098021786998-7744237703674395386?l=tech-turf.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-turf.blogspot.com/feeds/7744237703674395386/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6713504098021786998&amp;postID=7744237703674395386' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/7744237703674395386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/7744237703674395386'/><link rel='alternate' type='text/html' href='http://tech-turf.blogspot.com/2007/07/creating-hourglass-cursor-in-web.html' title='Creating Hourglass cursor in Web-Applications'/><author><name>Mayank</name><uri>http://www.blogger.com/profile/01711884180204765247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6713504098021786998.post-2936683336776907707</id><published>2007-07-24T09:27:00.000+05:30</published><updated>2007-07-25T15:40:54.541+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='XSLCustomFunctions'/><category scheme='http://www.blogger.com/atom/ns#' term='XSL'/><category scheme='http://www.blogger.com/atom/ns#' term='XSLT'/><title type='text'>Adding Custom Functions to XSL using XSLT Extensions</title><content type='html'>&lt;div align="justify"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;Many times it is our requirement to perform various types of processing in XSL file using functions. There are many in-built functions in XSL for doing various types of tasks like string manipulation, number calculations etc but sometimes we need to do some custom processing which can only be achieved by writing our own custom functions. These custom functions can be written in either JavaScript or in some other language. This BOK focuses on how to write these custom functions in a .NET compliant language (like VB.NET, C#) and then use it in our XSL file.&lt;br /&gt;&lt;br /&gt;Here are the steps to achieve the same:-&lt;br /&gt;&lt;br /&gt;1. Create the custom function in a class. If you need to write many custom functions, it is better to place these functions in a separate class; otherwise the function can be written in same class file as your calling code.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;Here a separate class “XSLCustomFunctions” is created which has a function for date formatting.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;color:#660000;"&gt;Public Class XSLCustomFunctions&lt;br /&gt;Public Function Format_Date(ByVal sDateTime As String) As DateTime&lt;br /&gt;Return CDate(sDateTime)&lt;br /&gt;End Function&lt;br /&gt;End Class&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;&lt;strong&gt;Point to Note&lt;/strong&gt; - Here class name is “XSLCustomFunctions” and custom function name is “Format_Date”&lt;br /&gt;&lt;br /&gt;2. Create an object of the custom function class. This has to be done in the function where the XSL transform is being applied.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;color:#660000;"&gt;Dim oCustFunc As New XSLCustomFunctions&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;3. Now we need to create XML namespace declaration in the XSL file for this custom class &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="font-family:courier new;font-size:85%;color:#000099;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="font-family:courier new;font-size:85%;color:#660000;"&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:myCustFunc="urn:custFunc"&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;?xml:namespace prefix = xsl /&gt;&lt;xsl:stylesheet version="1.0" xsl="http://www.w3.org/1999/XSL/Transform" mycustfunc="urn:custFunc"&gt;&lt;/div&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;strong&gt;&lt;xsl:stylesheet version="1.0" xsl="http://www.w3.org/1999/XSL/Transform" mycustfunc="urn:custFunc"&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;div align="left"&gt;&lt;/span&gt;&lt;xsl:stylesheet version="1.0" xsl="http://www.w3.org/1999/XSL/Transform" mycustfunc="urn:custFunc"&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;Point to Note&lt;/strong&gt; – Here “myCustFunc” is the XML namespace which refers to “urn:custFunc”. This will be passed as XSL extension while adding XSL extension object in step 5 &lt;/span&gt;&lt;/span&gt;&lt;/xsl:stylesheet&gt;&lt;/div&gt;&lt;p&gt;&lt;xsl:stylesheet version="1.0" xsl="http://www.w3.org/1999/XSL/Transform" mycustfunc="urn:custFunc"&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;color:#000099;"&gt;&lt;strong&gt;&lt;xsl:stylesheet version="1.0" xsl="http://www.w3.org/1999/XSL/Transform" mycustfunc="urn:custFunc"&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;div align="left"&gt;4. Use the custom function in the XSL at the required place. Please note that function is used in the format – “XML_NameSpace:CustomFunction”. &lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;/span&gt;&lt;/span&gt;&lt;xsl:value-of select="myCustFunc:Format_Date(Value)"&gt;&lt;xsl:value-of select="myCustFunc:Format_Date(Value)"&gt;&lt;span style="font-family:courier new;color:#000099;"&gt;&lt;/span&gt;&lt;/xsl:value-of&gt;&lt;/xsl:value-of&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;xsl:value-of select="myCustFunc:Format_Date(Value)"&gt;&lt;xsl:value-of select="myCustFunc:Format_Date(Value)"&gt;&lt;span style="font-family:courier new;font-size:85%;color:#660000;"&gt;&amp;lt;xsl:value-of select="myCustFunc:Format_Date(Value)" /&amp;gt;&lt;/span&gt;&lt;/xsl:value-of&gt;&lt;/xsl:value-of&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;xsl:value-of select="myCustFunc:Format_Date(Value)"&gt;&lt;xsl:value-of select="myCustFunc:Format_Date(Value)"&gt;&lt;br /&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;5. Create an object of XSLT argument list in the VB.NET code and add extension object to it and then only apply the XSL transform.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#660000;"&gt;&lt;span style="font-family:courier new;"&gt;Private Function ApplyXSLTransform(ByVal sXml As String) As String&lt;br /&gt;&lt;br /&gt;Dim oArgsList As New XsltArgumentList&lt;br /&gt;Dim oXmlDocument As New XmlDocument&lt;br /&gt;Dim oXslTransform As New XslTransform&lt;br /&gt;Dim oStringWriter As New System.IO.StringWriter&lt;br /&gt;Dim oCustFunc As New XSLCustomFunctions&lt;br /&gt;&lt;br /&gt;oXmlDocument.LoadXml(sXml)&lt;br /&gt;oXslTransform.Load(Server.MapPath("xsl_doc.xsl"))&lt;br /&gt;&lt;br /&gt;oArgsList.AddExtensionObject("urn:custFunc", oCustFunc)&lt;br /&gt;&lt;br /&gt;oXslTransform.Transform(oXmlDocument, oArgsList, oStringWriter, Nothing)&lt;br /&gt;&lt;br /&gt;Return oStringWriter.ToString&lt;br /&gt;End Function&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;In this way, we can use our own custom functions created in VB.NET/C# in the XSL file. &lt;/span&gt;&lt;/div&gt;&lt;/xsl:value-of&gt;&lt;/xsl:stylesheet&gt;&lt;/xsl:value-of&gt;&lt;/xsl:stylesheet&gt;&lt;br /&gt;&lt;/xsl:stylesheet&gt;&lt;span style="font-family:georgia;font-size:85%;"&gt;&lt;strong&gt;&lt;em&gt;~Mayank&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/xsl:stylesheet&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6713504098021786998-2936683336776907707?l=tech-turf.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-turf.blogspot.com/feeds/2936683336776907707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6713504098021786998&amp;postID=2936683336776907707' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/2936683336776907707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/2936683336776907707'/><link rel='alternate' type='text/html' href='http://tech-turf.blogspot.com/2007/07/adding-custom-functions-to-xsl-using.html' title='Adding Custom Functions to XSL using XSLT Extensions'/><author><name>Mayank</name><uri>http://www.blogger.com/profile/01711884180204765247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6713504098021786998.post-3855309968054478564</id><published>2007-07-23T11:29:00.001+05:30</published><updated>2007-07-23T12:33:21.353+05:30</updated><title type='text'>Launch of  Tech Turf</title><content type='html'>&lt;p align="justify"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;From quite some time, I have been thinking of staring a technical blog. I already have my personal blog at &lt;/span&gt;&lt;a href="http://diaryofmayank.blogspot.com/"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;http://diaryofmayank.blogspot.com/&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt; . While my personal blog is restricted to topics and happenings revolving around myself, the technical blog will be purely focused on my daily technical learning, new topics I learn and implement in my professional work. Sometimes, I learn quite a few things by searching on various website etc. Some links are quite interesting sometimes but I am never able to keep track of them. They always get lost in the myriad web. This blog is an attempt to keep track of all those learning and also share it with the whole world.&lt;br /&gt;&lt;br /&gt;With that, I announce the launch of my &lt;a href="http://tech-turf.blogspot.com/"&gt;Tech-Turf&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Hoping this blog will become a center of learning not only for me but for others too.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;&lt;strong&gt;&lt;em&gt;~Mayank&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6713504098021786998-3855309968054478564?l=tech-turf.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-turf.blogspot.com/feeds/3855309968054478564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6713504098021786998&amp;postID=3855309968054478564' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/3855309968054478564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6713504098021786998/posts/default/3855309968054478564'/><link rel='alternate' type='text/html' href='http://tech-turf.blogspot.com/2007/07/from-quite-some-time-i-have-been.html' title='Launch of  Tech Turf'/><author><name>Mayank</name><uri>http://www.blogger.com/profile/01711884180204765247</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
