Tuesday, March 31, 2009

Monitor pressed keys in C# ASP .NET text box controls

Similar to the way you can add a confirmation dialog box to a form, you can also monitor keystrokes within your text boxes and fire events off depending on which button is being pressed. This can help restrict certain buttons, or provide a specific key combination to perform a certain actions. Here's how to do it:

protected void Page_Load(object sender, EventArgs e)
{

if(!IsPostBack)
{
TextBox1.Attributes.Add("onkeydown", "if((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {alert('Please do not use the Enter key'); return false;} else return true;");
}

}

What this code does is define the "onkeydown" attribute for the text box named "TextBox1". In the example, it checks to see if the user is pressing the Enter key, and if so, displays an alert dialog box telling them not to. By having it return false, it then does not process that keystroke either. If they do not press Enter, then it returns true and the character they typed shows up in the text box. 

My need for this is that I didn't want users pressing Enter to skip lines in a multi-line text box. This worked perfectly, and could be used for all kinds of other purposes related to which keys are pressed at a certain point within a form. The original post I used to come up with this can be found here.

Thursday, March 26, 2009

Exchange error c103102e6 when adding new email address

If you're trying to add a new email address to a recipient policy, but receive an error c103102e6, don't worry. It just means that you forgot to include the '@' symbol in your email address. Add that in front of the email address you're adding to the recipient policy, then try again. You can find the same solution in MS KB 839500 too.

Free, easy to use network IP address scanner

I've used Angry IP Scanner numerous times to search for devices on the networks I manage. It's a really nice tool to have, and since it's free there's no reason not to. In fact, I've used it twice this week to figure out what IP addresses a couple of devices had after getting plugged in to the network (they were using DHCP). It works great for identifying those devices and active hosts, which cuts down on time trying to guess or having to gain access to the DHCP records to get information.

Wednesday, March 25, 2009

C# ASP .NET web form confirmation dialog box

I didn't realize just how simple it was to include a confirmation dialog box in a C# .NET web form. This is very useful for avoiding incorrect submissions, or those pesky accidental Enter press submissions. Here's how you can do it:

Assuming you have a Button control defined in your form, and lets say its name/ID is Button1. Button1 is also your form submission button. If you want to provide the user a confirmation box to make sure they mean to submit, you can add a single line of code to the Page_Load section of the code-behind file.

protected void Page_Load(object sender, EventArgs e)
{

if(!IsPostBack)
{
Button1.Attributes.Add("onclick", "return confirm('Ok to submit?');");
}

} 

By adding the "onclick" attribute, this will produce a dialog box with the text "Ok to submit?", with buttons for Ok and Cancel. If the user clicks Ok, the form will continue processing the submission. If they click Cancel, the submission doesn't happen and they can fix their info before submitting.

I added the if(!IsPostBack) so the Page_Load only processes this once. Otherwise it would add the attribute each time the page was posted back to the server. It's not that it would cause any major issues, but the more efficient the code, the better off you'll be. I found it at http://forums.asp.net/t/1213430.aspx, and they had other options to consider if you're interested in more information.

Monday, March 23, 2009

Fix SQL Server error 0xc00470fe

I ran into this error when trying to import data from a spreadsheet and .csv file to an existing SQL database. The import data wizard was able to create the table correctly, but it wouldn't import any of the existing data. I did a quick Google search and found out that the problem had a pretty simple fix. I thought the server already had integration services installed, but apparently it didn't. In order to import the data, you need to make sure integration services are installed. To do that, just put your SQL Server installation CD in the drive and go through the install process. During the installation, you're given the options for what you'd like to install. Check the Integration Services box and continue. Don't check any others unless you understand what they are and feel that you know what you're doing. Finish the install, then go back and try importing your data again. I bet it'll be ok.

Friday, March 20, 2009

Check IBM/Lenovo, Dell, HP, Apple, and other warranty status

Ever wondered whether your system or equipment was still covered under a warranty? I know I have. It's not always easy to keep track of warranty information when multiple machines are involved. However, some companies do allow you to check the status of a warranty on the web, as long as you know the serial number or service tag of the device. Here are links to IBM/Lenovo, Dell, HP, and Apple's warranty information lookup pages. If you know of others, please leave a comment with a link and the name of the manufacturer.

IBM/Lenovo

Apple

Dell

HP

Updated 3/22/2009

Western Digitial

Lexmark

Seagate

Tuesday, March 17, 2009

Windows Vista, event ID 10 repeatedly shows up in log

I was diagnosing an issue with a Windows Vista laptop and ran across this. Event ID 10 errors were in the event log repeatedly, and even though I didn't think it was related, I found a solution. You can find it in MS KB 950375.

You need to create a visual basic file, .vbs, using NotePad, with the following code inside:

strComputer = "." 
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\subscription")

Set obj1 = objWMIService.Get("__EventFilter.Name='BVTFilter'")
set obj2set = obj1.Associators_("__FilterToConsumerBinding") 
set obj3set = obj1.References_("__FilterToConsumerBinding") 

For each obj2 in obj2set 
WScript.echo "Deleting the object" 
WScript.echo obj2.GetObjectText_ 
obj2.Delete_ 
next 

For each obj3 in obj3set 
WScript.echo "Deleting the object" 
WScript.echo obj3.GetObjectText_ 
obj3.Delete_ 
next 

WScript.echo "Deleting the object" 
WScript.echo obj1.GetObjectText_ 
obj1.Delete_

To create the .vbs file, you'll either need to use Save As from within Notepad, or you'll have to show extensions on files so you can change them.

After you have your .vbs file with the code above inside, you need to run it with administrative priveleges. The easiest way to do this is from the command line. Right-click the shortcut to the command prompt, and select "Run as administrator". If you don't have a shortcut, you can find the program at C:\Windows\system32\cmd.exe on your computer. From here, run your .vbs file from the command prompt and it should take care of the problem. You can do that by simply typing in the full path to the file, e.g. C:\Users\username\Desktop\test.vbs, and pressing Enter. If there are spaces in any of the directory names in the path, be sure to surround the entire path with double-quotes.

Intermittent connection with Intel PROSet wireless card

I ran into a problem with some built-in Intel wireless cards in a couple of IBM machines a few weeks back. I reformated and reinstalled Windows, but for some reason after the reinstall the wireless cards weren't able to stay connected. The other thing that was happening is that after it dropped the wireless network it wouldn't be able to find any other available networks, or I'd see some of the networks but would get an error when I tried to join any of them. I double-checked the drivers, played with the BIOS, contacted IBM, tried the Windows and Intel wireless software, but nothing seemed to help. I'm using a Cisco WAP and had never had any issues with it before. The firmware is probably a little older, but since the wireless cards were working prior to the Windows reinstall, I didn't expect the router to be causing the problem. That's when I was finally able to find an answer with the help of some Google searching.

The power management and roaming aggressiveness built into the Intel driver can apparently cause problems, such as intermittent connectivity. The fix is relatively simple, but doesn't involve a driver update. You have to have administrative privileges in order to do this:

1. Right-click the My Computer icon and select Manage
2. Go to Device Manager 
3. On the right, click the + to expand Network Adapters
4. Locate your Intel wireless card, right-click on it, then select Properties
5. Go to the Advanced tab.
6. In the Property box, scroll through and look for Power Management. Make sure it is set to Highest. Uncheck "Use default value" if you have to. This will make sure that the wireless card isn't having any problems staying powered on.
7. Go back to the Property box and look for Roaming Aggressiveness. Make sure this setting is set to Lowest. Again, uncheck the "Use default value" box if you have to in order to change this setting. This will keep your wireless card from trying to jump back and forth between wireless networks.
8. Click OK, then close the Computer Management console
9. Restart, and hopefully things start working like they should 

I did find others say that upgrading their wireless access point/router did help solve their issue, so feel free to try that if this doesn't work. Like I said above though, for my problem I didn't need to and it didn't seem like it should have mattered anyway.

Here's a note from Intel. It doesn't mention the roaming aggressiveness, but I had found that in some forum notes somewhere. The combination that I gave above is what solved the problem for me, but feel free to try your own combo.

Monday, March 16, 2009

No hard drives found during Windows installation

If you're trying to install Windows on a machine, but run into an error that says that no hard drives were found, it's one of two things. Either the hard drive you're working with is faulty and truly not available, or the driver needed to communicate with the hard drive is not one of the defaults loaded on the Windows installation CD. Hopefully it's the latter, and if you have the drivers on a floppy, and the computer actually has a floppy drive, then you're set. If not, it's actually not that hard to fix with some free software, a CD burner, and a Windows install disc.

I actually found a really good help guide here: http://www.howtogeek.com/howto/windows/resolving-setup-did-not-find-any-hard-disk-drives-during-windows-xp-installation/. Because that one is done so well, I'm not going to reiterate it, but rather direct you right to that site. The just of it is that you need to create a new XP install disc using a free program called nLite. During the creation process, you will be given the option to include drivers for your hard drive, which you can usually download from the computer manufacturer's website if you don't already have them. At the end, you can create an .ISO file, which can then be burned to a CD and used to install Windows on the machine.

If you're just looking to find a way to include new service packs or updates in your XP install so you don't have to run Windows Update 10 times after you're finished, nLite handles that as well. My previous post about slipstreaming updates includes directions on how to do this, but nLite looks to be much more simple to use.

Friday, March 13, 2009

Reset Blackberry to factory defaults and wipe information

If you're going to sell a Blackberry you don't want anymore, are having weird problems, or just want to start over, you can reset the phone to the factory defaults pretty easily. This will erase all user information from the phone and it will then be as if it just came out of the box for the first time, minus the physical wear and tear. Anyway, to reset your phone, follow these instructions:

1. From the icon screen, go to Options, then into Security Options
2. Press the Menu button to bring up the menu, then select "Wipe Handheld"
3. Is should ask you to confirm the erase, so agree to that
4. Type "blackberry" when prompted. This is a safety feature to make sure you really do want to wipe the phone.
5. That's it. Now wait for the device to finish resetting itself, then you can do whatever you were going to do with it

If you're worried that you may need something from the phone afterwards, be sure to use Blackberry Desktop Manager to create a backup of it prior to resetting. This method performs a hard reset, so once it is finished your data is lost. The only way you'd be able to recover it would be from a backup.