Lowercase alone enable for Password field.

Posted by Oswaldlily under ASP.NET on 4/25/2013 | Points: 10 | Views : 722 | Status : [Member] | Replies : 1
In Password field(Textbox) ,if Caps lock is on ,it should pop out with messages "Caps lock is on" and shd resist typing in Capital(Uppercase)..
hw to do this


Posted by: Nvskhan on: 4/25/2013 [Member] Starter | Points: 25

add the namespace

using System.Runtime.InteropServices;

include in your class

static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
UIntPtr dwExtraInfo);

then in textbox enter event

private void textBox1_Enter_1(object sender, EventArgs e)        {            if (Control.IsKeyLocked(Keys.CapsLock)) // Checks Capslock is on            {                const int KEYEVENTF_EXTENDEDKEY = 0x1;                const int KEYEVENTF_KEYUP = 0x2;                keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);                keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,                (UIntPtr)0);            }        }
you can use this in keyup or keydown alos

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response