I have seen a lot of ASP.Net examples that show you the markup required to display a page with a password and a confirm password text boxes, together with the validation controls.

The majority of the examples however only show you how to make a password mandatory and how to check that the two passwords inside the text boxes are the same. While this is all fine and works, I also want to show you how you can configure the validation controls to make the password entry optional.

The code below can be used when you want to make the password optional, so there is no RequiredFieldValidator in it. However if the user types some text in any one of the password fields, I now want to make both of the text boxes to be the same, and so now they both become mandatory. This is achieved by using two CompareValidator controls, one for each TextBox.

<asp:TextBox ID="txtAccountPassword" runat="server" TextMode="Password"> </asp:TextBox>

<asp:CompareValidator ID="cmpvldPassword" runat="server" ControlToCompare="txtAccountPasswordConfirm" ControlToValidate="txtAccountPassword" Display="Dynamic" ValidationGroup="update" ForeColor="Red" ErrorMessage="*"></asp:CompareValidator>

<asp:TextBox ID="txtAccountPasswordConfirm" runat="server" TextMode="Password"></asp:TextBox>

<asp:CompareValidator ID="cmpvldPasswordConfirm" runat="server" ControlToCompare="txtAccountPassword" ControlToValidate="txtAccountPasswordConfirm" Display="Dynamic" ValidationGroup="update" ForeColor="Red" ErrorMessage="*"></asp:CompareValidator>

One example where I have used this is when I built an application where I wanted users to configure automated tasks by using their domain accounts. The users had the option to associate tasks to run under a particular account, but it was not necessary to enter a password for an account that was already stored in the database. The password and confirm password fields were only mandatory when a new user was being entered or the password needed to be changed.

I want to tell you that I have a program in my toolbox that I generally use to get information about the running services from a remote computer via WMI. It is written in ASP.Net/C#.

But that’s not what this is all about.

All of a sudden it broke down and did not work anymore. Result: Today I have been staring at this line of text just below for about two whole hours, trying to understand why it was generating an Invalid Query exception.

QueryString = "Select * from Win32_NTLogEvent WHERE LogFile='Application' AND SourceName='Outlook' AND TimeGenerated > '31/05/2012 05:15:52'"

It looks tame enough, but it does not work. The problem was that WMI expects the dates to be in the reversed US of A format. I always knew this was the case for SQL Server, but alas I did not make the connection with WMI. If you pass the date in a different format it will not work, so you will need to change its format before passing the request to the server. This code snippet shows you one way how it can be done.

This declaration goes at the top:

using System.Management;

and this here is the fixed code:

ManagementScope scope = new ManagementScope("\\\\" + address + "\\root\\cimv2");
scope.Connect();

ObjectQuery wql = new ObjectQuery(@"Select * from Win32_NTLogEvent WHERE LogFile='Application' AND SourceName='Outlook' AND TimeGenerated > '" + DateTime.Now.AddHours(-threshold1).ToString("MM/dd/yyyy HH:mm") + "'");

ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, wql);

ManagementObjectCollection results = searcher.Get();

foreach (ManagementObject result in results)
{
    // do something interesting
}

In the above code, address and threshold1 are two variables that respectively hold the name of the computer that you want to check and the time range from which you want to get the events.

Incidentally, only now do I remember that I have changed the regional settings on my computer from US to UK a couple of days ago.

I was reading a Wikipedia article recently, which inspired me into preparing something that is a bit different than usual for this month.

Something different as in here is a short game named Highnoon, which is an HTML/Javascript/JQuery rewrite of a 1970 game of the same name. I tried to stay close to the original game as possible, and meant to keep all the original’s interactions intact.

The original Highnoon, was text-based and written in BASIC by Chris Gaylo. In the game the player takes turns with the AI to enter their strategy in order to win the game. My version is still text based, but you can select the options with a mouse-click (or a tap of your finger, depends on the type of device that you are using) instead of typing in the number related to your choice as in the original Highnoon. So, if you were expecting a 3D remake you will not find it here. However you can also download the source code to see an example of how basic logic is done in Javascript. Now get playing Highnoon!

Wild West image by nitch-stock, and is made available through the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.

I know that it has been due for a looong time, but your favorite desktop wallpaper management software is just in time for being February's monthly release from edvella.com.

The main purpose of this updated version is to make DeskDeco natively compatible with Windows 7. If you are still using a pre-Win XP machine, keep using the old version. In the next release, I will add some nice new features, made possible by modern coding practices and whatnot. So stay tuned.

Don’t be the one to hear about the DeskDeco experience from your friends; download it now yourself!

I am just now applying the finishing touches to the first version of the software to show caller information whenever an emergency call on the 112 service comes in. Requested by the EU and operated by the country's police department, by means of this software the call centre agent will be able to see the caller's details (such as location) and handle the call as required. System testing is going to start soon. Meanwhile, here is a snippet from the program's documentation:

“The implementation of the 112 Emergency Services software is divided into two sections, namely the administration program and the agent program. The administration program is meant to be installed on the server, and is used to configure the server’s configuration. Eventually it will also be used to generate the required call logging reports. The agent client program is to be installed on all agent computers. The main function of the client program is to display the name and address of the caller that has dialled into the 112 emergency services. This program also has the secondary functions of call handling (answer/transfer/release) and call tagging (for reporting purposes)” Photo: The Times of Malta

Buy me a coffee Buy me a coffee