001. 为input type=text 时设置默认值
1. 前端HTML代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!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>HTML服务器控件</title>
<script type="text/javascript" runat="server">
//protected void Page_Load(Object sender, EventArgs e) //如果在当前页面设置Load事件, 那么.cs文件中的load的事件将会被覆盖
//{
// this.MyText.Value = "hello world!"; //设置input的默认值
//}
</script>
<style type="text/css">
#MyText
{
width:188px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<input id="MyText" type="text" runat="server" />
</form>
</body>
</html>
2.下面是.cs中的load事件, 如果页面中有Page_load事件, 那么该事件将会被覆盖 (Page_load事件→页面初始化事件)
using System;
using System.Collections.Generic;
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)
{
if (!IsPostBack)
{
this.MyText.Value = "我是首次加载";
}
else
{
this.MyText.Value = "我不是首次加载";
}
}
}
001. 为input type=text 时设置默认值的更多相关文章
- select2 插件编辑时设置默认值
function htDate(selectCustomerId, val) { var customerId = selectCustomerId; var values = val; ajaxJs ...
- .NET DateTime类型变量作为参数时设置默认值
一个小的 Tips. .NET 中函数参数的默认值需要是编译时常量.如果参数是引用类型,可以设置Null,如果是值类型,可以设置相应的编译时常量,如整型可以用整数,但对于DateTime(结构体,值类 ...
- <input type="text"/>未输入时属性value的默认值--js学习之路
在百度ife刷题是自己的一个错误引发了我对<input type="text"/>的学习. 先贴代码: <!DOCTYPE html> <html&g ...
- html设置<input type="text">内的内容自动为大写
添加css样式:text-transform:uppercase;可以实现自动转换为大写样式. 但是input 的value还是小写的,因为它是CSS样式. <input type=" ...
- HTML:<input type="text"> 输入数字时的验证!(在提交时验证)
<!--非负数:<input type="text" name="" pattern="^\d+$">--> < ...
- <input type="text">和<textarea>的区别
在我们开发时经常需要用到输入框,通常解决办法就是<input type="text">和<textarea>,那么这两个标签有什么区别呢? 一:<i ...
- html5与js关于input[type='text']文本框value改变触发事件一些属性的区别oninput,onpropertychange,onchange和文本框的value点击全选状态onclick="select();"。做购物车页面时会要用到。
关于input[type='text']文本框value改变触发事件一些属性的区别oninput,onpropertychange,onchange和文本框的点击全选状态onclick="s ...
- chrome下input[type=text]的placeholder不垂直居中的问题解决
http://blog.csdn.net/do_it__/article/details/6789699 <input type="text" placeholder=&qu ...
- java 反射: 当Timestamp类型的属性值为null时,设置默认值
import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.lang.reflect.Metho ...
随机推荐
- python中的namespace
python中的名称空间是名称(标识符)到对象的映射. 具体来说,python为模块.函数.类.对象保存一个字典(__dict__),里面就是重名称到对象的映射. 可以参看下面python程序的输出: ...
- 《view programming guide for iOS 》之可以使用动画效果的属性
frame—Use this to animate position and size changes for the view. ,框架,可以视图动态改变大小和位置 bounds—Use this ...
- Interview----First single charactor
题目:在一个字符串中找到第一个只出现一次的字符.如输入 abaccdeff,则输出 b. 分析:这道题是 2006 年 google 的一道笔试题. 分析: 用 Hash, 时间和空间复杂度是 O(N ...
- 解决MindManager缺少mfc100u.dll无法启动的难题-转载
很多应用软件的运行环境离不开组件,MindManager也不例外.很多用户在成功安装MindManager之后,却显示无法找到组件mfc100u.dll,mfc100u.dll是MindManager ...
- 电话 SMS 邮件 网页 AppStore
//调用safar打开网页 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.cnbl ...
- 【转】Polymer API开发指南 (一)(翻译)
原文转自:http://segmentfault.com/blog/windwhinny/1190000000592324 翻译的不好,轻拍 Polymer是google的一款前端开发框架,其基于Sh ...
- Linux关机命令
1.halt :关机 init 0 : 关机 shutdown -h now (立刻关机) -h 指的是 halt 2.reboot 重启 init 0 重启 shutdown -r no ...
- HttpServlet详解
http://www.cnblogs.com/panjun-Donet/archive/2010/02/22/1671290.html Servlet的框架是由两个Java包组成:javax.serv ...
- 【ES5】hideProperty
function hideProperty(host, name, value) { Object.defineProperty(host, name, { value: value, writabl ...
- Word Ladder II
Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformat ...