I've been keeping a running collection of tips/tricks that I felt made my life easier as a developer. I hope this collection has you feeling the same way. Feel free to post a comment at the bottom if there are others you found useful as well.
1. Visual Studio. Conditional breakpoints. Have you ever right clicked a breakpoint when developing in visual studio? If you have then you would know there are a slew of break options. You can break when a certain 'Condition' is met (i.e. x = 5), when a certain hit count is reached (i.e. after 5 hits). This should speed up your debugging.
2. Visual Studio. If you want to comment or un-comment an entire block of code inside visual studio. Highlight the block of code and select <Ctrl>+<K> and then <Ctrl>+<C> ... if you wish to un-comment a block, then use <Ctrl>+<K> and then <Ctrl>+U. This works in both Visual Studio as well as SQL Management Studio.
3. Visual Source Safe. When in Visual Source Safe you may use the keyboard shortcut <Ctrl>+<S> to see all files currently checked out, globally, or to a specific user. Additionally you can search within only the current project, or the entire VSS database.
4. Visual Studio. If you want to see a history of all edits to your file when you are in Visual Studio, you may right click the file in Solution Explorer and select "View History".
5. Javascript. When including a script file on a site with an SSL certificate, use the html markup <script src=”//www.company.com/scripts/file.js”> approach for preventing the security ('This page contains secure and non-secure items) dialog pop-up. Notice that the http: portion is gone, but it will render properly regardless of the current protocol.
6. Javascript. In addition to #3, if you would like to obtain the current protocol which is in use in your Javascript, you may obtain that by issuing the following command:
var prefix = window.parent.document.location.protocol + '//';
7. Javascript. If you wish to get the object which caused the asynchronous postback on an asp.net ajax enabled page. You may use the following code:
var ClientId;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_InitializeRequest(InitHandler);
function InitHandler(sender, args) {
ClientId = args.get_postBackElement().id;
alert(ClientId);
}
8. SQL. If you need to remove a set of duplicate records, try using the following statements.
SELECT MyDuplicateColumn, MyDuplicateColumn2, Count(*) - 1 As NumToDelete FROM MyTableWithDuplicates GROUP BY MyDuplicateColumn, MyDuplicateColumn2 HAVING COUNT(*) > 1
Then while looping through the records in the above recordset, issue the following command:
DELETE TOP (NumToDelete) FROM MyTableWithDuplicates WHERE MyDuplicateColumn = 'MyDupeValueFromPreviousQuery' AND MyDuplicateColumn2 = 'MyDupeValueFromPrevousQuery2'
