ASP.net – Using enter key in a textbox to trigger a button event as well as set focus and select text in the text box

Ok, that’s probably the longest post title I’ve used yet.
Here’s what I’m working with: a form with a textbox a button and a listbox.  Users enter text into the textbox and hit the button to search for information which is returned into the listbox.
The first issue was I don’t want to have to click the search button to start the search.  I wanted to be able to just hit enter after typing text.  The button triggers vb code behind the page to do the search.

So I found adding the following to the Page_Load sub-routine allowed me to hit enter in the textbox which triggers the button code:

txtSearch.Attributes.Add(“onkeypress”, “return clickButton(event,'” + btnSearch.ClientID + “‘)”)

Replace txtSearch with the id of your textbox and replace btnSearch with the id of your button.

Next, I wanted the text in the textbox to be highlighted/selected after performing a search so you could turn around and type something else and do another search without touching the mouse.
This is accomplished by adding the following to the Page_Load sub-routine:

Me.txtSearch.Focus()
txtSearch.Attributes.Add(“onfocus”, “JavaScript:document.getElementById(‘” + txtSearch.ClientID + “‘).select();”)

Replace txtSearch with the id of your textbox.

Note:  Sometimes when you copy and paste code like that above the quotes and or apostrophes can get funky and need to be corrected.

Wallpaper – Tubes

Click image for 1920 x 1080 version.
You may use this image for personal use only.  Please contact me for business use.

  • Camera: NIKON D7000
  • Taken: 1 November, 2011
  • Aperture: ƒ/3.8
  • Focal length: 21mm
  • ISO: 200
  • Shutter speed: 1/40s

Desert Lizard

Click image for 1920 x 1080 version.
You may use this image for personal use only.  Please contact me for business use.

  • Camera: NIKON D7000
  • Taken: 31 October, 2011
  • Aperture: ƒ/5.6
  • Focal length: 300mm
  • ISO: 250
  • Shutter speed: 1/2000s

Microsoft Hyper-V error: Hypervisor driver required is not installed or is disabled

I wanted to test out Microsoft Sharepoint Server and decided to test it on a Hyper-V virtual server.  I guess I’ve finally learned not to experiment directly on production servers finally.  That tends to possibly cause problems.
So, on one of my servers which I had recently updated to Windows Server 2008 R2 I decided to add the Hyper-V role and setup a test server.  After adding the role I kept getting error messages and Hyper-V wouldn’t start.

The error stated:
‘Hypervisor’ driver required by the Virtual Machine Management service is not installed or is disabled.  Check your settings or try reinstalling the Hyper-V role.

After some Googling I found several people saying I needed to make sure No-Excecute Memory Protection and Intel Virtualization Technology were enabled in the bios.  I was familiar with the second setting and had enabled it on machines before but not the first.  My server is an HP DL380 G5 and here are the steps for fixing the issue:

1.  Reboot the server and hit F9 to enter the Bios.
2.  Go to Advanced options > Processor Options
3.  Find the “No-Excecute Memory Protection” and enable it. (Hit enter)
4.  Find the “Intel(R) Virtualization Technology” and enable it. (Hit enter)
5.  Save and exit using F10

After reboot my Hyper-V is all happy and functioning.

Enable Ping responses on Windows Server 2008

I use Ping (not the sort of ping in the picture above) to make sure I can communicate with my servers all the time.  Windows Server 2008 doesn’t allow Ping responses through the Windows Firewall.
Here’s how to enable Ping responses:

Open the Windows Firewall Advanced settings (Open Network and Sharing Center, click Windows Firewall bottom left, then Advanced settings).

Find the File and Printer sharing (Echo Request – ICMPv4-In) in the Inbound Rules section and ICMPv6 if you want to enable IPv6 responses.
Double click each rule and select enabled or right-click and select Enable Rule.

You should now be able to ping the server.

.

  • Camera: SGH-i937
  • Taken: 22 January, 2012
  • Aperture: ƒ/2.65
  • Focal length: 4.03mm
  • ISO: 50
  • Shutter speed: 1/15s

Einstein on God

image
I am reading a biography on Einstein and found this paragraph interesting. A reporter asked Einstein if he believed in God.
“I am not an atheist,” he began. “The problem involved is too vast for our limited minds. We are in the position of a little child entering a huge library filled with books in many languages. The child knows someone must have written those books. It does not know how. It does not understand the languages in which they are written. The child dimly suspects a mysterious order in the arrangement of the books but doesn’t know what it is. That, it seems to me, is the attitude of even the most intelligent human being toward God. We see the universe marvelously arranged and obeying certain laws but only dimly understand these laws.”
The universe is indeed marvelously arranged.

Wallpaper – Nevada somewhere

Click image for 1920 x 1080 version.
You may use this image for personal use only.  Please contact me for business use.

  • Camera: NIKON D7000
  • Taken: 31 October, 2011
  • Aperture: ƒ/4.5
  • Focal length: 18mm
  • ISO: 100
  • Shutter speed: 1/640s