Justin Cooney

Web Development Tips and Examples

  • A fairly common task is to add or remove user or group permissions to a SQL Server Stored Procedure, and also to maintain a list of database objects and the permissions associated with them.

    The syntax for these actions has remained fairly similar throughout the various versions of SQL Server, although SQL Server 200 and before do have different methods for querying the system tables. I have tested the add/remove/report syntax shown below on SQL Server 2008.

    Remember that when you are using these commands it is identical to grant permissions to a database user as it is to a database group.

    (more…)

  • In this article I’ll cover two useful regular expressions that often come in handy when writing validation logic for a Web page. Most programmers will find they need to either validate a URL or an Email at some point, and the example expressions below are the most commonly used versions of each expression.

    I’m not sure who originally created  each of these expressions, so I have no idea who I can give the credit for these to, but they have helped me often. Bottom line for these two examples is that I like to use the example expressions found in an article on NetTuts+/regular-expressions.info and modify them to meet my needs.

    Since I’m mentioning the regular-expressions.info site, I definitely suggest browsing over to it if you are looking for further reading about regular expressions including sample code and reference material.

    Also, have a look at a free online regular expression tool by Derek Slager. You can use this tool to test your regular expressions if you don’t have a program on your computer to do so. I have spent quite some time trying to find a good online regular expression testing tool, but every one I have found is either too expensive, or full of advertising, so this tool is definitely worth checking out.

    (more…)

  • GridView with a JQuery Dialog
    GridView with a JQuery Dialog

    Recently I wanted to use the stock JQuery UI modal dialog confirmation widget with an ASP.NET GridView control. The image above shows the basic setup that I wanted the GridView to have.

    As you can see, the grid should have several data columns followed by a column containing Checkboxes. The JQuery dialog should be triggered by the click event of each Checkbox. When the user clicks on a Checkbox in the GridView, the JQuery dialog should appear only if a Checkbox has already been selected. Furthermore, the user should be given two buttons as actions. The OK button will allow the check to happen, but the Cancel button will undo the check of the Checkbox.

    (more…)