Home » Articles posted by Justin Cooney
Author Archives: Justin Cooney
ShowModalDialog Example – How to Save Popup Form Information and Close the Modal Popup Window
In this article I will go through a technique that you can use when working with a modal popup that lets you store form information from your popup to later use with your main Web form.
In earlier articles I have covered some of the general functions and benefits of using the ShowModalDialog function that I will expand on this article. If you have questions about some of the code I’ve used in this article, then please take a look at my earlier articles that might help explain some of the concepts:
T-SQL – Compare Stored Procedure Versions Between Two Databases
If you have several different versions of the same database then you will want to be able to check for differences in the objects between the databases. You can quickly and easily do so using SQL Server’s sys.objects or if you are specifically looking up stored procedures, SQL Server’s sys.procedures system views.
Let’s take an example use case where if you have a development and a deployment database and you want to check what procedures in development that you (or someone on your team) has worked on that you should now move to deployment. Normally it’s not too difficult to remember, but if there are a large number of small changes or a long time has passed since you made the changes, then you’ll need to run a simple difference comparison between the two databases to remember what procedures you need to migrate.
Luckily you can simply type in your comparison query in SQL Server Management Studio (SSMS). This is as powerful and granular as you want it to be and can be just as accurate as specially written custom tools. Unlike custom tools though, this method comes with SQL Server and just requires a bit of understanding of the sys.objects system view.
Have a look at other articles I’ve written about SQL Server if you find this article to be useful. (more…)
Notes on Finding your WordPress.com Site Map and RSS Feed for Bing and Google
You can find this information scattered all over the Web, but I want to make a note of where to find your WordPress XML Site Map and RSS feed.
By the way, the Site Map and RSS feed URLs are just for sites hosted on WordPress.com and not self-hosted WordPress sites, but the WebMaster Tools information is applicable to everyone.
Knowing the location of your RSS and Site Map is especially useful information to have at hand when you are registering your site with Bing or Google. In both search engines it’s a good idea to submit both your RSS feed and your Site Map to their site maps section.
Basically I’m putting together this article to keep a list of useful links in place to refer to when managing one’s WordPress Web site. I have some other articles that cover general Web development topics that you might find interesting if you found this article useful. (more…)
ASP.NET – Handling Null Return Values from the Database using IsDBNull
If you are retrieving or adding values from and to your database then you will know the difficulties that can be caused by NULL values. The notorious InvalidCastException is one example of receiving a NULL value from your database into an ASP.NET object that doesn’t know what to do with database NULL values.
Here’s typical example of an InvalidCastException error caused by setting a String variable to a value that is returned as a NULL from your database query:
System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid. at Microsoft.VisualBasic.CompilerServices.Conversions.ToString(Object Value) at ASP.myPageName_aspx.Page_Load(Object sender, EventArgs e) in D:\Inetpub\wwwroot\MySite\myPageName.aspx:line 1xx
If you find this article useful, have a look at some of the other ASP.NET tips and tricks articles I’ve published. (more…)
T-SQL – Get a Historical Record of SQL Statements Hitting a Table
Today I’ll review two useful queries that you can use to get information from SQL Server about what SQL statements are hitting one or more of your database tables.
If you are interested in further T-SQL tips and tricks, please have a look through related articles I have written. (more…)
SQL Server Upserts – Using MERGE to INSERT or UPDATE Table Rows
The idea of an Upsert was added in the SQL 2003 standard for databases and is implemented using a MERGE statement in both Oracle and SQL Server.
So You Might Ask: What is an Upsert?
An Upsert does pretty much does what it sounds like: it runs an update on a row where a condition exists and it runs an insert if the condition does not exist.
What are the Benefits of Using a MERGE Upsert
If you look at the difference between a conditional INSERT…UPDATE code snippet and a MERGE statement you will see that the MERGE statement does have its benefits.
- For starters, the MERGE statement is less verbose and encapsulates the entire logic of the Insert/Update into a single statement. This is beneficial for readability and maintainability.
- Also the MERGE statement is more performant since SQL Server needs to deal with one query rather than a several separate queries and a temporary variable.
- The MERGE statement runs as a single atomic statement and so you don’t need to manually encapsulate it in a transaction like you would with the conditional version.
Upserting in SQL Server
Since I like to code for SQL Server I thought I’d try out using the MERGE statement as an Upsert. In doing so it’s important to note that Microsoft added support for the MERGE statement as of SQL Server 2008, so the MERGE statement will not work on older versions of SQL Server.
As an aside, the MERGE statement can be used for more than Upserting. But in this article I will specifically focus in this article about how to use the MERGE statement as an UPSERT to add or update information in a single table.
If you find this article useful and would like to read more about SQL Server and T-SQL, feel free to check out other SQL Tips and Tricks I have written. (more…)
T-SQL – Replace Multiple Extra Whitespaces in a String with One Whitespace
In this article I will review three easy methods that can be used to replace extra spaces between words in a string. Note that if you want to remove extra spaces from the start and end of your string you will still need to encapsulate the output of the routines within the standard LTrim / RTrim functions.
Each of these methods works quite nicely and can either be written directly into your code, or can be added as a user-defined function. I have tested these functions in SQL Server 2000 and SQL Server 2008 and they work very well in either of these versions of SQL Server.
Please have a look at some of the other aricles I have written covering SQL Server. (more…)
T-SQL – Using the OUTPUT Clause to Get Identity Keys and Log Historical Data
The OUTPUT clause is a useful part of your T-SQL arsenal that has been added as of SQL Server 2005. You can use the OUTPUT clause in the same vein as @@IDENTITY, IDENT_CURRENT, or SCOPE_IDENTITY(), or even extend it to be a historical logging mechanism.
Unlike @@IDENTITY, or SCOPE_IDENTITY(), you need to populate a table rather than a variable when using the OUTPUT clause. This of course has its advantages as well in that you are able to log batch operations and easily store before/after historical information.
Further, Microsoft itself recommends using the OUTPUT clause rather than the @@IDENTITY or SCOPE_IDENTITY() since the latter two can cause problems if your queries use parallel execution plans. Have a look at the Microsoft Knowledgebase Article on the topic: http://support.microsoft.com/kb/2019779 (more…)
Reviewing the Popularity of 5 Commonly Used Server-Side Programming Languages
I’ve always been curious about the popularity of the most commonly used programming languages, but haven’t been able to find a reliable (non-biased) source.
I decided to take matters into my own hands and use the Google trends tool to see the frequency with which five of the most commonly used server-side programming languages have been referenced worldwide in the past twelve months (ranging from April 25 2012 to April 25 2013.) (more…)
REST API: Add a plain text file as an attachment to a list item
SharePoint 2013 REST API has been enhanced and extended. The old _vti_bin/listdata.svc is still there, but the new api for working with lists and list items is much more and obviously a part of a bigger api: _api/web/lists
Yesterday I saw an interesting question on SharePoint StackExchange:
JQuery 2.0 – Notes About the Official Release
The latest news coming from the world of jQuery is the official release of jQuery 2.0.
The new jQuery 2.x library is a significantly smaller file size than the jQuery 1.x series of libraries, but the 2.0 library does not support versions of Internet Explorer prior to version 9.
For the foreseeable future, the makers of jQuery plan to run two separate lines of the jQuery library:
- The jQuery 1.x library will continue to be developed for years to come and will support older browser versions.
- On the other hand, the jQuery 2.x library will support newer browsers and will offer both a smaller file size, and likely modern features that older browsers can not support.
Note: Have a look at this series of articles covering jQuery if you find this post interesting and want to read more about the subject. (more…)
JQuery – Example of Tabs Event Handling
If you are working with JQuery tabs and want to extend the functionality of your tabs beyond the basics, then it’s good to know how to handle the JQuery tabs click event.
In this article I will:
- Review how to add event handling to the JQuery tabs when a tab is clicked
- I will show how to load an iFrame contained in a tab when the tab is selected.
If you like this article, please have a look here for further useful articles about JQuery.
JavaScript / JQuery – Click Button by ID
In this article I will review how you code a button click event in JavaScript, and how it differs from a button click event in JQuery. I’ll also show some integration of the client-side JavaScript with server-side code in both identifying an ASP.NET button control in JavaScript, and in making the button click event trigger a post-back to the Web server.
Structure of the Example
As you can see in the image above (and the example code below), I’ve coded both a JavaScript and a JQuery button, and have added ASP.NET button controls beside each that will get clicked when the user clicks the JavaScript or JQuery button.
I have written further useful articles about JQuery and JavaScript that are worth having a look at if you are interested in these languages. (more…)
HTML5 – Useful Links for Developers
As 2013 the HTML5 standard is still actively being developed and revised, and it is not fully supported by any Web browser. There are a number of tools freely available to HTML5 developers that help enhance browser support for HTML5 and that add to the speed and ease of developing a site.
In this article I will review some of the major tools, frameworks, libraries, and online resources that anyone working with HTML5 will find useful. Also make sure to read more about HTML5 in my series of articles.
(more…)
Setting the Z-Index and Page Position of a JQuery Modal Dialog
The JQuery modal dialog widget can be a useful tool on most Web pages. If you take a look at its structure in a tool such as FireBug you will see that it consists of a div that grays out the web page’s background, and another div that sits on top and that presents the modal dialog.
If you are adding absolute positioning and z-index markup to your Web page, then you will want to look a little deeper into the properties of your modal dialog widgets and how they interact with other elements on your Web page.
When an area of your page has a higher z-index than your modal dialog does, then the dialog will not be modal for that area, and may even be hidden by the area entirely. For example, if you have a text field on your form that is wrapped in an element with a z-index that is higher than that of your modal dialog, then your modal dialog will not gray out the text field. Even worse, the text field will remain editable which is certainly not desirable behavior.
If you find this article interesting, then take a look at my collection of articles on JQuery and the JQuery Modal Dialog widget.



















