===第一种===================================================================================================
<script type="text/javascript">
function validateLogin()
{
if (document.getElementById("<%= TextBoxLoginName.ClientID %>").value == "") {
alert("名称不能为空");
return false;
}
if (document.getElementById("<%=TextBoxLoginPassword.ClientID %>").value == "") {
alert("密码不能为空");
return false;
}
}
function CancelLogin()
{
document.getElementById("<%=TextBoxLoginName.ClientID %>").value = "";
document.getElementById("<%=TextBoxLoginPassword.ClientID %>").value = "";
}
</script>
<fieldset>
<legend style="text-align:center" >登陆CMS后台管理</legend>
<form id="form1" runat="server" action="/User/Login"> //提交服务器 //2
管理员:<asp:TextBox ID="TextBoxLoginName" runat="server" ></asp:TextBox>
<br />
密 码 :<asp:TextBox ID="TextBoxLoginPassword" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="ButtonOK" runat="server" Text="登陆" OnClientClick="return validateLogin()"/> //登陆时验证非空 //1
<span style="margin-left:30px;"></span>
<asp:Button ID="ButtonConcel" runat="server" Text="取消" OnClientClick="CancelLogin()"/> //清空 //1
</form>
</fieldset>
********************
功能:登陆功能正常
弊端:点击“取消_清空"按钮后,可以清空,但是也提交服务器,加重负担
=============================================================================================================
===第二种====================================================================================================
<fieldset>
<legend style="text-align:center" >登陆CMS后台管理</legend>
<form id="form1" runat="server">
管理员:<asp:TextBox ID="TextBoxLoginName" runat="server" ></asp:TextBox>
<br />
密 码 :<asp:TextBox ID="TextBoxLoginPassword" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="ButtonOK" runat="server" Text="登陆" PostBackUrl="/User/Login"/> //提交服务器
<span style="margin-left:30px;"></span>
<asp:Button ID="ButtonConcel" runat="server" Text="取消"/>
</form>
</fieldset>
********************
功能:登陆功能正常
弊端:“登陆"按钮,本人不会加验证,应为OnClientClick="return validateLogin()"和 PostBackUrl="/User/Login"不共存
只能在后台加验证(服务端向客户端注册脚本块)
================================================================================================================
随机推荐
- .Net程序员学用Oracle系列(5):三大数据类型
<.Net程序员学用Oracle系列:导航目录> 本文大纲 1.Oracle 数据类型概述 2.字符类型 2.1.字符集 & NLS 2.2.常见的两种字符串 2.3.NCHAR ...
- Java集成开发环境--Eclipse for J2EE配置JRE运行环境
.d1 { border-style: none } .d2 { border-style: solid } .d3 { border-style: dotted } .d4 { border-sty ...
- jquery中这句 .stop(false,true); 什么意思
.stop 是jQuery中用于控制页面动画效果的方法.运行之后立刻结束当前页面上的动画效果.stop在新版jQuery中添加了2个参数:第一个参数的意思是是否清空动画序列,也就是stop的是当前元素 ...
- SQL Server 2016 的「動態資料遮罩 (Dynamic Data Masking)」
一些特別注重資訊安全.個人資料的公司或產業 (如: 金融.保險業),通常「測試用資料庫」的資料,會加上「遮蔽:去識別化」的功能,避免個資外洩.以往必須自己撰寫 SQL 語句或 Stored Proce ...
- table排名次
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Idea高级用法
一.快速打开Action: Ctrl+Shift+A 列表中会列出所有的action,对应于idea的各种操作,例如: 输入backgroud,可以为编辑器设置背景 输入restclient,可以打开 ...
- 微信小程序前置课程:flex布局(二)
原文:http://www.ruanyifeng.com/blog/2015/07/flex-examples.html 上一篇文章介绍了Flex布局的语法,今天介绍常见布局的Flex写法. 你会看到 ...
- spring boot maven 插件
spirng boot 需要使用专用maven插件打包,才能打包.引入如下. <build> <plugins> <plugin> ...
- dirty cow exp
公司搞底层的改了一下,说做到了几个不死机 /* * (un)comment correct payload first (x86 or x64)! * * $ gcc cowroot.c -o cow ...
- 工具-maya2014软件操作细节(持续更新……)
整体 ------------------------------------------------------- [全选控制器] 1.选中总控-显示-隔离选择-查看选定对象 2.全选并创建新层(不 ...