using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; //导入命名空间 using System.Runtime.InteropServices; namespace WebAppLock { public partial class WebForm1 : System.Web.UI.Page { [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)] public static extern int GetKeyState(int Key); protected void Page_Load(object sender, EventArgs e) { if ((GetKeyState(20) & -1) > 0) { Label1.ForeColor = System.Drawing.Color.Red; Label1.Text = "大写琐打开"; } else { Label1.Text = ""; } } } }
这样可以显示,但是只有一次,后来我在控件上加了autopostback,要好一点,基本实现,但是需要刷新页面.
我不知道大家有没有别的办法!我现在只能做到这一步!
改自:
http://blog.csdn.net/yzhxhwt/archive/2007/08/02/1721960.aspx