039. asp.netWeb用户控件之七实现具有虚拟键盘的功能的用户控件
用户控件ascx代码:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Keyboard.ascx.cs" Inherits="Keyboard" %>
<link href="js/jquery.keypad.alt.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery.keypad.js"></script>
<script type="text/javascript">
$(function () {
//初始化keypad插件
$('#defaultKeypad').keypad({prompt:'',keypadOnly:false,layout:$.keypad.qwertyLayout});
});
</script>
<input id="defaultKeypad" type="password" name="pwd" maxlength="12" style="width:150px"/>
用户控件ascx.cs代码:
public partial class Keyboard : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{ }
/// <summary>
/// 返回虚拟键盘取得的值
/// </summary>
/// <returns></returns>
public string getvalue()
{
System.Collections.Specialized.NameValueCollection nv = new System.Collections.Specialized.NameValueCollection(System.Web.HttpContext.Current.Request.Form);
return nv.GetValues("pwd")[].ToString();
}
}
Default.aspx代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register src="Keyboard.ascx" tagname="Keyboard" tagprefix="uc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.style1
{
width: 144px;
height: 36px;
}
.style2
{
width: 152px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table align="center" cellpadding="0" cellspacing="0" >
<tr>
<td class="style2">
用 户 名:</td>
<td class="style1">
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
</td>
<td class="style3">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtUserName" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style2">
密 码:</td>
<td class="style1">
<uc1:Keyboard ID="Keyboard1" runat="server" />
</td>
<td class="style3">
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style1">
<asp:Button ID="Button1" runat="server" Text="登录" onclick="Button1_Click" />
<input id="Button2" type="button" value="退出" onclick="window.close();"/></td>
<td class="style3">
</td>
</tr>
</table>
<br />
<br /> </div>
</form>
</body>
</html>
Default.aspx.cs代码:
protected void Button1_Click(object sender, EventArgs e)
{
if (Keyboard1.getvalue() != "")
{
//获取用户输入的信息, 包括登录名和通过软键盘输入的面
string info ="登录名:"+txtUserName.Text+"登录密码:"+Keyboard1.getvalue();
//弹出提示, 以便测试查看
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('"+info+"');", true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入密码');", true);
}
}
示例中用到的js文件下载:
http://pan.baidu.com/s/1kVyPxZp
最终效果图:

039. asp.netWeb用户控件之七实现具有虚拟键盘的功能的用户控件的更多相关文章
- 033. asp.netWeb用户控件之二将页面转换成web控件和使用Web控件显示热点新闻
访问Web用户控件的属性 ASP.NET提供的各种服务器控件都有其自身的属性和方法,程序开发人员可以灵活地使用服务器控件中的属性和方法开发程序.在用户控件中,程序开发人员也可以自行定义各种属性和方法, ...
- ASP.NET--Web服务器端控件和Html控件
今天学习总结了一些相关概念和知识. 之前无论是做 单机的winform 还是 CS的winform 感觉,不到两年下来感觉还可以,虽然API有很多,但是还是比较熟悉基于WINDOWS消息机制的编程,但 ...
- ListView控件的Insert、Edit和Delete功能(第一部分)
摘自:http://blog.ashchan.com/archive/2007/08/28/listview-control-insert-edit-amp-delete-part-1aspx/ Li ...
- 实现带查询功能的Combox控件
前言 ComBox 还可以实现查询功能,通过设置 ComBox 控件的 AutoCompleteSource 属性和 AutoCompleteMode 属性,可以实现从 Combox 控件中查询已存在 ...
- 五:理解控件的运行机制(例:基于Control命名空间的简单控件)
一:先用最简短的话说点理论的1.asp.net中所有的标准控件都可以重写 2.和控件相关的命名空间有 System.Web.UI.Control是所有控件的基类只提供简单的呈现逻辑,不支持样式表 Sy ...
- ios开发中关闭textview控件的虚拟键盘
在ios开发中,textfield控件在点击的时候出现虚拟键盘,关掉虚拟键盘可以通过虚拟键盘中的done button和点击view中的任意地方来关闭虚拟键盘. 1.第一种方法是textfield控件 ...
- MVC5 网站开发之七 用户功能 2 用户添加和浏览
目录 MVC5网站开发之一 总体概述 MVC5 网站开发之二 创建项目 MVC5 网站开发之三 数据存储层功能实现 MVC5 网站开发之四 业务逻辑层的架构和基本功能 MVC5 网站开发之五 展示层架 ...
- MVC5 网站开发之七 用户功能 3用户资料的修改和删除
这次主要实现管理后台界面用户资料的修改和删除,修改用户资料和角色是经常用到的功能,但删除用户的情况比较少,为了功能的完整性还是坐上了.主要用到两个action "Modify"和& ...
- Android 使用代码主动去调用控件的点击事件(模拟人手去触摸控件)
使用代码主动去调用控件的点击事件(模拟人手去触摸控件) //View 可以是LinearLayout,Button,TextView View.performClick();
随机推荐
- JQuery中$.ajax()方法参数都有哪些?
url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如put和 ...
- 【转】 shell 判断语句
转自:http://see.sl088.com/wiki/Shell_%E4%B8%AD%E6%8B%AC%E5%8F%B7 test 和 [] test -z string 判定字串是否為 0 ?若 ...
- 2014年7月份第1周51Aspx源码发布详情
QF万能视频播放器源码 2014-6-30 [VS2010]本源码是一个万能视频播放器源码.可实现各种格式的影片播放功能. 1.点击[开始]按钮,弹出窗口,选择影片路径,确定后即可播放.可拖拽滚 ...
- poj3662 最短路+二分
//Accepted 508 KB 79 ms //spfa+二分 //二分需要的花费cost,把图中大于cost的边设为1,小于cost的边设为0,然后spfa求 //最短路,如果小于K则可行,继续 ...
- 为PHP安装两个扩展,memcache和Redis
最近由于学习Discuz,发现Discuz对于memcache和Redis都有支持,为了看一看开启这些支持之后的神器效果,所以在window上配置了下这两个扩展 环境说明:OS:windows 7 服 ...
- Java SCP copy local file to remote implementation
最近做的项目中,有一个小需求,需要通过SCP把本地文件copy到远程服务器.查了好多资料,最终解决方案简单快速,分享一下. 在这里,需要用到4个jar包,分别是ant-jsch.jar,ant-lau ...
- schematool -dbType mysql -initSchema hive startup failed...try this
schematool -dbType mysql -initSchema hive startup failed
- c++unsigned char的输出问题
unsigned char的范围是0~255,在用cout输出的时候要显示数字的话记得进行int的强制转化才可以,否则都是输出的字符,除此之外的所有比较转换成整数在做比较吧 除此之外,在最近的项目里由 ...
- C#知识体系(一) --- 常用的LInq 与lambda表达式
LinQ是我们常用的技术之一.因为我们绕不开的要对数据进行一系列的调整,如 排序. 条件筛选.求和.分组.多表联接 等等. lambda则是我们常用的语法糖,配合linq使用天衣无缝,不知不觉就用上了 ...
- span标签跳转新页面
<span onclick="javascript:window.open('http://eccu.fr/guanli/login.aspx')" style=&quo ...