Sending mail with ASP.NET and Gmail

After a server upgrade I had to setup my mail again. It seems that IIS7 has lost it’s core mail functionality, so I tried to use the SMTP service from Gmail for sending my e-mail. First thing I did is to setup a simple test page, that I would like to share with you. Front The page contains a simple web form for inserting some test data and is looking like this:           The markup code   <%@ Page Language="C#" AutoEventWireup="true" CodeFile="gmail_mailtest.aspx.cs" Inherits="SendMail" %> <html> <head runat="server"><title... [More]

Using .NET methods in your XSLT

Not many people know that it is possible to use a .NET object as an extension object when transforming XML with XSLT. Imagine that you want to recalculate the price of a book and round the result number. Impossible to calculate within XSLT, since it’s a transformation language and not a programming language. Solution is to create a class with a method that performs the calculation. Then when transforming add this opject as an extension object to the XsltArgumentList. The C# code:   public class BookPrice { public decimal NewPrice(decimal price, decimal conv) ... [More]

Two useful jQuery scripts for forms

Here are two useful jQuery scripts for online forms. The first is to prevent double submission of a form a.k.a. ‘anti-double-click’. $("form").submit(function() { $(":submit",this).attr("disabled", "disabled"); }); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .... [More]

SQL Server database table sizes

To get a good overview of the amount of data that resides in your database tables, you can use this handy T-SQL scripts. CREATE PROCEDURE [dbo].[GetDBTableSize] AS BEGIN SET NOCOUNT ON; DECLARE @cmdstr varchar(100) --Create Temporary Table CREATE TABLE #TempTable ( [Table_Name] varchar(50), Row_Count int, Table_Size varchar(50), Data_Space_Used varchar(50), Index_Space_Used varchar(50), Unused_Space varchar(50) ) --Create Stored Procedure String SELECT @cmdstr = 'sp_msforeachtable ''sp_spaceused "?"''' --Populate Tempoary Table INSERT INTO #TempTable EXEC(@cmdstr... [More]

Find stored procedures, tables and functions in T-SQL

When developing a lot in database, it can be useful to search for database objects that contain (partly) a specific name. The stored procedure script below allows you to perform such a search. /* Find stored procedures / tables / functions */ CREATE procedure dbo.pr_FindIt ( @find varchar(128) ) as SELECT TABLE_SCHEMA AS OBJECT_SCHEMA, TABLE_NAME AS OBJECTNAME, TABLE_TYPE AS OBJECT_TYPE, null as CREATED, null as LAST_ALTERED, null as SQL_DATA_ACCESS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE '%' + @find + '... [More]