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字符decode与encode的问题
同事在工作中遇到一个字符编码的问题:问题是:从mysql数据库中读出来的varchar类型数据在python是unicode类型的. 但他却对这个unicode字符进行了decode,因为他以为读出来 ...
- 技术解析:锁屏绕过,三星Galaxy系列手机也能“被”呼出电话
近期,由两位安全研究人员,Roberto Paleari及Aristide Fattori,发布了关于三星Galaxy手机设备安全漏洞的技术细节.据称,Galaxy手机可在锁屏状态下被未授权的第三方人 ...
- Osmocom-BB 相关资源、知识分享
1.在layer1层添加了解析sniffer的代码 参考http://git.osmocom.org/osmocom-bb/log/?h=luca/gsmmap)osmocom-bb/src/targ ...
- 深入分析:Fragment与Activity交互的几种方式(二,使用Bundle)
首先我们需要在Activity中动态添加Fragment时,用Bundle封装我们需要传递的数据. public void button(View view) { ArgFragment arg = ...
- 30道四则运算<1>
#include<iostream> using namespace std; #define random()(rand()%100) class shuzi //shuzi类的功能是产 ...
- exit(-1)或者return(-1)为什么shell得到的退出码是255?
写一段hello world: // filename: main.c #include <stdio.h> int main(void) { printf("hello wol ...
- Day09_面向对象第四天
1.多态的概念和前提(掌握) 1.概念-什么是多态(掌握) 对象在不同时刻表现出来的不同状态. 2.针对引用类型的理解 编译期间状态和运行期间状态不一样 比如 ...
- Java 内部类和匿名类 实现JButton动作 ActionListener类
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class ControlCircle2 extend ...
- What books does Bjarne Stroustrup suggest to master C++?
QUESTION : What books does Bjarne Stroustrup suggest to master C++? ANSWER: A Tour of C++ is a quick ...
- 66. Plus One
Given a non-negative number represented as an array of digits, plus one to the number. The digits ar ...