[转]asp的textbox的javascript应用
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server"> </script>
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript">
//javascript设置文本框的最大长度
function Button1_Click()
{
var txtBox1=document.getElementById("TextBox1");
txtBox1.maxLength=10;
return false;
}
//javascript设置文本框的属性为只读
function Button2_Click() {
var txtBox1=document.getElementById("TextBox1");
txtBox1.readOnly=true;
return false;
}
//javascript设置行数与文本框类型 //将<input type=text />改成<textarea /> //id号不变
function Button3_Click()
{
//移除TextBox1
var textBox1=document.getElementById("TextBox1");
var textBox1id=textBox1.id; //得到TextBox1的父元素
var parentE=textBox1.parentElement; parentE.removeChild(textBox1);
//创建新元素
TextArea var newTextBox1=document.createElement("<textarea />");
newTextBox1.id=textBox1id;
newTextBox1.name=textBox1id;
newTextBox1.rows=10;
parentE.appendChild(newTextBox1);
// parentE.insertBefore(newTextBox1,textBox1);
return false;
}
//javascript设置文本框的文本
function Button4_Click()
{
var txtBox1=document.getElementById("TextBox1");
txtBox1.value='中国。河北。保定。曲阳。王爱辉';
return false;
}
//javascript设置鼠标移过去显示文本
function Button5_Click()
{
var txtBox1=document.getElementById("TextBox1");
txtBox1.title='曲阳县第一中学';
return false;
}
//设置文本框的可见性 //可能是将TextBox1控件从dom树中删除
function Button7_Click()
{
var txtBox1=document.getElementById("TextBox1");
return false;
}
//javascript设置是否自动换行 //只对<textare />有效
function Button6_Click()
{ return false; }
</script>
</head>
<body>
<form id="form1" runat
相关文档:
自己写的一个简易计时器,能记算代码的执行时间,还可以拿来测试代码的执行效率。
function Counter(){
this.start();
}
Counter.prototype.getTime = function(){
var time = new Date();
return time.getSeconds()*1000+time.getMilliseconds();
}
Counter.prototype.start = function(){
this. ......
进一步理解javascript对象、数组和哈希表
在javascript中,对象实际上就是一个哈希表,比如下面这个user对象:
function user(n, a)
{
this.name = n;
this.age = a;
this.toString = function() {
return 'Name:' + ......
书接上文,直接从字符串返回对象,此次更新,实现了返回对象的自动化,无需在声明实体类。但这个函数只适合页面声明几个对象,批量对象,比如几百个,推荐使用下一文所使用函数。
函数很简单,不解释,直接贴代码。
option explicit
'返回对象的函数
function getObj(byval str)
dim classname,itemlist,i
cl ......
在asp:UpdatePanel控件中直接使用FileUpload,服务端是无法找到上传文件的。
只要在<Trigger>中添加button就可以解决这个问题
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
......