ASP.NET TextBox 当鼠标点击后清空默认提示文字
ASP.NET TextBox 当鼠标点击后清空默认提示文字
[ 方法一]
前台代码:
<div>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:TextBox ID="txtPwd" runat="server"></asp:TextBox>
<asp:Button ID="btnLongin" runat="server" Text="提交" />
</div>
后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//用户输入
txtName.Attributes.Add("Value", "请输入用户名");
txtName.Attributes.Add("OnFocus", "if(this.value=='请输入用户名') {this.value=''}");
txtName.Attributes.Add("OnBlur", "if(this.value==''){this.value='请输入用户名'}");
//密码输入
txtPwd.Attributes.Add("Value", "请输入密码");
txtPwd.Attributes.Add("OnFocus", "if(this.value=='请输入密码'){this.value=''}");
txtPwd.Attributes.Add("OnBlur", "if(this.value==''){this.value='请输入密码'}");
//
if (!IsPostBack)
{
//内容
}
}
}
[ 方法二]
前台文本框里添加下面2个事件属性:
OnFocus="javascript:if(this.value=='提示文字') {this.value=''}"
OnBlur="javascript:if(this.value=='') {this.value='提示文字'}"
-----------------------------------例-----------------------------------------
<asp:TextBox ID="txtName" runat="server" Text="请输入用户名"
OnFocus="javascript:if(this.value=='请输入用户名') {this.value=''}"
OnBlur="javascript:if(this.value==''){this.value='请输入用户名'}">
</asp:TextBox>
<asp:TextBox ID="txtPwd" runat="server" Text="请输入密码"
OnFocus="javascript:if(this.value=='请输入密码') {this.value=''}"
OnBlur="javascript:if(this.value==''){this.value='请输入密码'}">
</asp:TextBox>
ASP.NET TextBox 当鼠标点击后清空默认提示文字的更多相关文章
- ASP.NET TextBox 当鼠标点击后清空默认提示文字[转]
前台文本框里添加下面2个事件属性: OnFocus="javascript:if(this.value=='提示文字') {this.value=''}" OnBlur=" ...
- c#鼠标点击TextBox控件后清空默认字体
方案(一) 脚本: <script type="text/javascript" language="javascript"> //得 ...
- winform Textbox模糊搜索实现下拉显示+提示文字
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 【WPF】设置TextBox内容为空时的提示文字
<TextBox Width="150" Margin="5"> <TextBox.Resources> <VisualBrush ...
- jQuery自定义组件——输入框设置默认提示文字
if (window.jQuery || window.Zepto) { /** * 设置输入框提示信息 * @param options * @author rubekid */ var setIn ...
- 给input标签添加默认提示文字
<input name="username" placeholder="请输入用户名" /> placeholder = "提示文字&qu ...
- input 默认提示文字 样式修改(颜色,大小,位置)
input::-webkit-input-placeholder{ color:red; font-size:20px; ...... }
- <input>/<textarea>输入框设置默认提示文字(隐藏式)
html代码如下: <tr> <td>签 名:</td> <td><input type="text" nam ...
- CSS实现input默认文字灰色有提示文字点击后消失鼠标移开显示
CSS实现input美化操作默认是为灰色,并且有提示 如下图 鼠标点击后文字消失,鼠标移开后文字显示 给input入下图添加代码 style="color:#cccccc; outline: ...
随机推荐
- C# RSA加密解密
1.解析密钥 /// <summary> /// 把二进制密钥解析成RSACryptoServiceProvider /// </summary> /// <param ...
- System系统类常用方法
System 系统类: 主要用于获取系统的属性数据. System类常用的方法: arraycopy(Object src, int srcPos, Object dest, int destPos, ...
- thinkPHP实现静态页的方法-buildHtml
thinkphp全站静态页实现方法! 1:在根目录下的全局index.php中加下面这行: define('HTML_PATH', './htm');//生成静态页面的文件位置 2:在项目的配置文件c ...
- (转载)Win8.1的版本
Win8.1版本到底有哪些? Windows 8.1的各版本有什么不同.差别和区别? Win8.1旗舰版有木有? Win8.1最好的版本是哪个? 我应该用哪个版本的Windows 8.1? 之前软媒曾 ...
- LinkedList源码阅读笔记(基于JDK1.8)
LinkedList是List接口的一个有序链表实现,存储节点是内部类Node,Node中有两个属性prev和next,负责连接前后两个元素.由于不是使用数组进行存储,所以查询需要遍历链表一半的元素( ...
- jQuery数据缓存方案详解:$.data()的使用
我们经常使用隐藏控件或者是js全局变量来临时存储数据,全局变量容易导致命名污染,隐藏控件导致经常读写dom浪费性能.jQuery提供了自己的数据缓存方案,能够达到和隐藏控件.全局变量相同的效果,但是j ...
- rake deploy ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to解决方法
需要修改项目中Rakefile文件的内容: 原始内容:system "git push origin #{deploy_branch}" 改后内容:system "git ...
- Web API Get Started First
注:此博客是自官网修剪而来,博主IT新手 一.web api与web service的不同: web api是基于Http协议,而web service是基于soap协议.两协议的区别小子看了很多,但 ...
- 使用 Graphviz 画拓扑图
使用 Graphviz 画拓扑图 0)前述 本文着重讲一下 Graphviz 的风格控制,基础一些的就不在这里讲啦. graphviz 的主页是http://www.graphviz.org/. Gr ...
- 压缩png质量不改变像素
private static byte[] CompressionImage(Bitmap bitmap, Stream fileStream, long quality) { using (Syst ...