把设计页的脚本代码方法添加到服务器按钮控件中的方法
2009-03-01 10:27
351 查看
<script language="javascript" type="text/javascript">
function showpic()
{
var picvalue=document.getElementById("HaedSelect").options[document.getElementById("HaedSelect").selectedIndex].value;
document.getElementById("haedimg").src=picvalue;
}
function Check()
{
if(document.getElementById("txt_username").value=="")
{
alert("用户名不能为空");
return false;
}
if(document.getElementById("txt_pwd").value!=document.getElementById("txt_repwd").value||document.getElementById("txt_repwd").value=="")
{
alert("两次输入的密码不一致或者密码为空!");
return false;
}
if(document.getElementById("txt_realname").value=="")
{
alert("真实姓名不能为空!");
return false;
}
if(document.getElementById("txt_sex").value=="")
{
alert("性别不能为空!");
return false;
}
if(document.getElementById("txt_nation").value=="")
{
alert("民族不能为空!");
return false;
}
return true;
}
</script>
//后台代码
this.Button1.Attributes.Add("onclick", "return Check()");
function showpic()
{
var picvalue=document.getElementById("HaedSelect").options[document.getElementById("HaedSelect").selectedIndex].value;
document.getElementById("haedimg").src=picvalue;
}
function Check()
{
if(document.getElementById("txt_username").value=="")
{
alert("用户名不能为空");
return false;
}
if(document.getElementById("txt_pwd").value!=document.getElementById("txt_repwd").value||document.getElementById("txt_repwd").value=="")
{
alert("两次输入的密码不一致或者密码为空!");
return false;
}
if(document.getElementById("txt_realname").value=="")
{
alert("真实姓名不能为空!");
return false;
}
if(document.getElementById("txt_sex").value=="")
{
alert("性别不能为空!");
return false;
}
if(document.getElementById("txt_nation").value=="")
{
alert("民族不能为空!");
return false;
}
return true;
}
</script>
//后台代码
this.Button1.Attributes.Add("onclick", "return Check()");
相关文章推荐
- 用一个例子讲述如何向ASP.NET Web服务器按钮控件添加客户端脚本
- 一步步学习微软InfoPath2010和SP2010--第三章节--表单设计基础:处理InfoPath布局、控件和视图(7)--添加含规则的提交按钮到Flight Delay表单
- VC为按钮控件添加图片的方法
- 让服务器控件的事件同时执行客户端脚本和服务器端代码-转载
- 为按钮控件添加图片的方法
- JS代码,将终端用户(Web 页面的查看者)的计算机时间置于一个按钮 Web 服务器控件上
- 向 ASP.NET Web 服务器控件添加客户端脚本事件
- JS脚本实现动态给标签控件添加事件的方法
- Repeater控件中添加删除按钮方法
- VC6注释添加工具条,及此工具条的代码设计编写方法。
- 向 ASP.NET Web 服务器控件添加客户端脚本事件
- ASP.NET 2.0中给DropDownList服务器控件添加项的新方法
- asp.net 服务器控件LinkButton等在后台代码中设置js事件或添加css样式
- ASP.NET 2.0中给DropDownList服务器控件添加项的新方法
- [转贴]编写服务器控件时,向页面写入脚本的方法
- .net编写服务器控件时,向页面写入脚本的方法
- Qt添加背景图片而不影响其控件的不用代码的设置方法
- 编写服务器控件时,向页面写入脚本的方法
- 如何在代码中动态添加按钮控件
- 向 ASP.NET Web 服务器控件添加客户端脚本事件