Monday, 18 February 2013

Enabling Developer tab within Excel Ribbon


Applies to Microsoft Excel with ribbons, starting from Excel 2007 as far as I can remember!

Thursday, 14 February 2013

ASP.NET page life cycle

Request --> Startup --> Initialization --> Loading --> Postback Handling --> Rendering --> Unloading!

The most comprehensive reference I can really recommend is within the MSDN:
http://msdn.microsoft.com/en-us/library/7949d756-1a79-464e-891f-904b1cfc7991.aspx

Tuesday, 12 February 2013

Hosts file location under Windows

%SystemRoot%\system32\drivers\etc\hosts

For older versions from windows:
%WinDir%\hosts

Monday, 11 February 2013

Backup DB using SQL statement


-- Name of the DB to backup, and destination directory
DECLARE @DBName VARCHAR(50)           
DECLARE @Destination VARCHAR(2000)

SELECT @DBName = 'DB',
  @Destination = '\\TestMachine\'
+ REPLACE(@@SERVERNAME, '\','_')
+ '_' + REPLACE(@DBName, ' ','_')
+ '_' + LEFT(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR, GETDATE(), 121), '-',''),':',''),' ','_'), 13) + '.bak'

--Sample Destination: \\TestMachine\DBServer_DB_20130211_1630.bak

PRINT 'Backup ' + QUOTENAME(@@SERVERNAME) + '.' + QUOTENAME(@DBName) + ' to file "' + ISNULL(@Destination, 'NULL') + '"'

BACKUP DATABASE @DBName TO DISK = @Destination WITH COPY_ONLY, COMPRESSION, STATS=5

N.B. Compression is not supported with standard editions.

Comprehensive TSQL options can be found at:
http://msdn.microsoft.com/en-us/library/ms186865.aspx

Sunday, 27 January 2013

Remove ASP.NET Membership Provider objects from SQL Server Database

%WINDIR%\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql.exe



Tip:
This also exists for .NET framework 2.0 in the equivalent directory

Wednesday, 23 January 2013

Simplest way to add a password strength indicator




Using ASP.NET AJAX Control toolkit:

<asp:TextBox ID="TextBox_Password" runat="server" Width="220px"></asp:TextBox>
<ajaxToolkit:PasswordStrength ID="PasswordStrength_Password" runat="server
   TargetControlID="TextBox_Password"
   DisplayPosition="RightSide"
 
   StrengthIndicatorType="BarIndicator"
 
   PreferredPasswordLength="8"
   MinimumNumericCharacters="1"
   MinimumSymbolCharacters="1"
   RequiresUpperAndLowerCaseCharacters="true"
 
   TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"
   BarBorderCssClass="barIndicatorBorder"
   StrengthStyles="barIndicator_VeryPoor; barIndicator_Weak; barIndicator_Average; barIndicator_Strong; barIndicator_Excellent"

   CalculationWeightings="50;15;15;20" />


Styles in css:

/*Password strength bar*/
.barIndicatorBorder {
    border: solid 1px #c0c0c0;
    width: 200px;
}

.barIndicator_VeryPoor {
    background-color: red;
}

.barIndicator_Weak {
    background-color: orange;
}

.barIndicator_Average {
    background-color: lightblue;
}

.barIndicator_Strong {
    background-color: greenyellow;
}

.barIndicator_Excellent {
    background-color: green;
}