Sat
Dec 30
2006

Disable Infragistics WebGrid

To simulate a disabled grid:

Grid.Bands(0).RowStyle.BackColor = Color.LightGray
Grid.Bands(0).RowStyle.ForeColor = Color.DarkGray
Grid.Bands(0).RowAlternateStyle = Grid.Bands(0).RowStyle
Grid.Bands(0).SelectedRowStyle = Grid.Bands(0).RowStyle
Grid.Bands(0).HeaderStyle.ForeColor = Color.DarkGray
Grid.BackColor = Color.LightGray
Grid.DisplayLayout.ClientSideEvents.BeforeSelectChangeHandler = "Grid_BeforeSelectChange"
Grid.DisplayLayout.ClientSideEvents.BeforeRowActivateHandler = "Grid_BeforeRowActivate"

Add to aspx:

  <script language="javascript">
    // Prevent the user from changing the currently active row
    function Grid_BeforeRowActivate(gridName, id)
    {
        igtbl_cancelPostBack(gridName);
        return 1;
    }
    // Prevent the user from changing the currently selected row
    function Grid_BeforeSelectChange(gridName, id)
    {
        igtbl_cancelPostBack(gridName);
        return 1;
    }
    </script>

To restore:

Grid.Bands(0).RowStyle = Grid.DisplayLayout.RowStyleDefault
Grid.Bands(0).RowAlternateStyle = Grid.DisplayLayout.RowAlternateStyleDefault
Grid.Bands(0).SelectedRowStyle = Grid.DisplayLayout.SelectedRowStyleDefault
Grid.Bands(0).HeaderStyle = Grid.DisplayLayout.HeaderStyleDefault
Grid.BackColor = Color.Transparent
Grid.DisplayLayout.ClientSideEvents.BeforeSelectChangeHandler = ""
Grid.DisplayLayout.ClientSideEvents.BeforeRowActivateHandler = ""
Tue
Nov 14
2006

IE Quick Search

With this tweak you can search Google by type “g searchterms” into the IE address bar. Other shortcuts: gg (Google Groups), ggd (Google Groupe limited to dotnet newgroups), mskb (Microsoft Knowledgebase), wiki (Wikipedia). Save this to a .reg file and double-click.

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl]
“provider”=”"

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl\g]
@=”http://www.google.com/search?q=%s”
” “=”+”
“#”=”%23″
“&”=”%26″
“?”=”%3F”
“+”=”%2B”
“=”=”%3D”

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl\gg]
@=”http://groups.google.com/groups?q=%s”
” “=”+”
“#”=”%23″
“&”=”%26″
“?”=”%3F”
“+”=”%2B”
“=”=”%3D”

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl\ggd]
@=”http://groups.google.com/groups?q=%s&as_ugroup=*dotnet*”
” “=”+”
“#”=”%23″
“&”=”%26″
“?”=”%3F”
“+”=”%2B”
“=”=”%3D”

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl\kb]
@=”http://support.microsoft.com/default.aspx?scid=kb;EN-US;%s”
” “=”+”
“#”=”%23″
“&”=”%26″
“?”=”%3F”
“+”=”%2B”
“=”=”%3D”

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl\mskb]
@=”http://support.microsoft.com/default.aspx?scid=kb;EN-US;%s”
” “=”+”
“#”=”%23″
“&”=”%26″
“?”=”%3F”
“+”=”%2B”
“=”=”%3D”

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl\ms]
@=”http://support.microsoft.com/search/default.aspx?Query=%s&KeywordType=ALL&maxResults=150″
” “=”+”
“#”=”%23″
“&”=”%26″
“?”=”%3F”
“+”=”%2B”
“=”=”%3D”

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl\wiki]
@=”http://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go”
” “=”+”
“#”=”%23″
“&”=”%26″
“?”=”%3F”
“+”=”%2B”
“=”=”%3D”

Fri
Oct 27
2006

Redirect Tracing to a File

<system.diagnostics> 
	<trace autoflush="true" indentsize="4"> 
			<listeners> n
			<add 	name="FileListener" 
				type="System.Diagnostics.TextWriterTraceListener" 
				initializeData="TraceLog2.txt" /> 
		</listeners> 
	</trace> 
</system.diagnostics>
Wed
Oct 25
2006

Detect Password Expiry

See the original Usenet posting.

public static DateTime PasswordExpirationDate(string user, string domain)
{
	string connect = String.Format("WinNT://{0}/{1},user", domain, user);
	DirectoryEntry entry = new DirectoryEntry(connect);
 
	if (entry == null)
		Console.WriteLine("Failed to get Directory Entry.");
 
	int secondsRemaining = (int)entry.Properties["MaxPasswordAge"][0];
 
	// A policy setting of -1 means no expiration,
	// so return an 'infinite' date
	if (secondsRemaining > 0) 
	{
		secondsRemaining -= (int)entry.Properties["PasswordAge"][0];
		return DateTime.Now.AddSeconds(secondsRemaining);
	} 
	else 
	{ 
		return DateTime.MaxValue; 
	}
}
Thu
Oct 19
2006

Hide property from the Visual Studio Designer

[Browsable(false), DesignerSerializationVisibility(
                            DesignerSerializationVisibility.Hidden)]
Tue
Oct 17
2006

Web Project Errors

When opening a web project:

The project you are trying to open is a Web project. You need to open it by specifying its URL path.

Create a file called c:\inetpub\wwwroot\Folder\MyProject.csproj.webinfo and add:

<VisualStudioUNCWeb>
    <Web URLPath = "http://localhost/Folder/MyProject.csproj" />
</VisualStudioUNCWeb>

More information

Sat
Oct 14
2006

Books to Check out

Agile Principles, Patterns and Practices in C# (Robert C Martin)
Applying UML and Patterns (Craig Larman)
The Pragmatic Programmer: From Journeyman to Master (Andrew Hunt, David Thomas)
Hibernate in Action (Bauer, King)
Effective Use of Microsoft Enterprise Library (Len Fenster)
- Books on effective unit testing
Refactoring (Martin Fowler)
The Humane Interface (Jef Raskin)

Sat
Oct 14
2006

.Net Articles

The Cost of GUIDs as Primary Keys
Creating and opening ASP.NET projects in Visual Studio .NET
VSS and Visual Studio .NET Information: Bindings, suo file, vss files explained.
Dispose, Finalization, and Resource Management

Thu
Oct 5
2006

Double.NaN Equality

Console.WriteLine(double.NaN.Equals(double.NaN)); // True
Console.WriteLine(double.NaN == double.NaN); // False
Tue
Sep 19
2006

Removing double.NaN from a SQL table

SQL Server’s float datatype does not support the double.NaN value. SQL and T-SQL will prevent these values from entering the database, but ADO.Net does not. Query Analyzer will stop displaying additional results once it hits a NaN value. Enterprise manager will display -1.#IND. Normal queries on this value will result in errors so it is difficult to remove them. The solution: convert to a string first.

UPDATE mytable
SET floatColumn = NULL
WHERE cast(floatColumn AS varchar(100)) = '-1.#IND'

Older Posts »

© 2006 Brian Low. All rights reserved.