ASP.Net Iterate through all Controls

Iterate through all Controls on a webpage, even one with a master page:

IterateThroughChildren(this);

void IterateThroughChildren(Control parent)
{
foreach (Control c in parent.Controls)
{
Debug.WriteLine(c.ID);

if (c.Controls.Count > 0)
{
IterateThroughChildren(c);
}
}
}

Advertisements

C# DateTime as a String

Working with DateTime to produce a usable date string ie: 2003-03-08 21:17:42

public String GetDateTimeString(DateTime dt)
{
StringBuilder sb = new StringBuilder();
sb.Append(dt.Year);
sb.Append(“-“);
if(dt.Month < 10)
sb.Append(“0”);
sb.Append(dt.Month);
sb.Append(“-“);
if(dt.Day < 10)
sb.Append(“0″);
sb.Append(dt.Day);
sb.Append(” “);
if(dt.Hour < 10)
sb.Append(“0”);
sb.Append(dt.Hour);
sb.Append(“:”);
if(dt.Minute < 10)
sb.Append(“0”);
sb.Append(dt.Minute);
sb.Append(“:”);
if(dt.Second < 10)
sb.Append(“0”);
sb.Append(dt.Second);
return sb.ToString();
}

Call with String xx = GetDateTimeString(DateTime.Now);

Rights Needed to Install SQL Server Developer Edition on Your Machine in a Secure Environment

ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeDebugPrivilege
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeCreateTokenPrivilege
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeServiceLogonRight
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeImpersonatePrivilege
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeInteractiveLogonRight
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeAssignPrimaryTokenPrivilege
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeChangeNotifyPrivilege
ntrights -u “YourAdminAccount” -m \\YourMachineName +r SeIncreaseQuotaPrivilege

Some Common Regular Expressions

Commonly used regular expressions that I have found and used.

Public Class CommonValidationExpressions
Public Shared Email As String =
“\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*”
Public Shared URL As String =
http://(%5B\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?”
Public Shared USPhone As String =
“((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}”
Public Shared SSN As String =
“\d{3}-\d{2}-\d{4}”
Public Shared ZIP As String =
“\d{5}(-\d{4})?”
Public Shared DateMMDDYYYY As String =
“^\s*\d{1,2}(/|-)\d{1,2}\1(\d{4}|\d{2})\s*$”
Public Shared IPAddress As String =
“^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]
[0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]
|1[0-9][0-9]|[1-9][0-9]|[0-9])$”
End Class

Unsigned Integers (Non-negative)
^\d+$
NoMatch: -1
Match: 0, 1, 999

Float
^-?\d*(\.\d+)?$

Positive Integer with upper bounds of 99.
^[1-9][0-9]{0,1}$

Positive Integer (No Upper Bounds) – this does not accept blanks
Matches: [2], [50], [0] [ More Details]
Non-Matches: [-15], [1.2]
^\d+$

Disable Conducting Experiments With This Machine By Microsoft

Disable Conducting Experiments With This Machine By Microsoft.

http://www.makeuseof.com/tag/10-windows-10-features-can-turn-off/

10 More Windows 10 Features You Can Turn Off regedit experiments 670x459

Alternatively, you can edit the Windows registry yourself. Open the Start Menu and type Regedit. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PolicyManager\current\device\System and set the Allow Experimentation key to 0 to turn off all experiments.