===第一种===================================================================================================
<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"不共存
只能在后台加验证(服务端向客户端注册脚本块)
================================================================================================================
随机推荐
- 配置supervisor 让laraver的队列实现守护进程
1,安装: #brew install supervisor 默认会安装在/usr/local/Cellar/supervisor目录 2,在etc下面新建supervisor.conf 文件,复制下 ...
- C# 关于委托的小例子
本例子是一个关于委托的小例子[猫叫,狗跳,人喊]. 委托是C#开发中一个非常重要的概念,理解起来也和常规的方法不同,但一旦理解清楚,就可以信手拈来,随处可用. 委托是对方法的抽象.它存储的就是一系列具 ...
- 前端MVC学习笔记(三)——AngularJS服务、路由、内置API、jQueryLite
一.服务 AngularJS功能最基本的组件之一是服务(Service).服务为你的应用提供基于任务的功能.服务可以被视为重复使用的执行一个或多个相关任务的代码块. AngularJS服务是单例对象, ...
- Dos.ORM Select查询 自定义列
自定义列 .Select( p = >new{ test = p.id}) // 同sql 列名 as 新列名 如下是 自己在写代码的例子,查询,分页,where条件,排序 var where ...
- Singleton Pattern(单例模式)
1.简介 单例模式,顾名思义,即在整个系统中,类的实例对象只有一个. 单例模式具有以下特点: 单例类只能有一个实例 单例类必须自己创建自己的唯一实例 单例类必须给所有其他对象提供这一实例 2.实现 其 ...
- Eclipse/MyEclipse 安裝後應該更改的設置
基本上都通過 Window -> Preferences 進行設置: Java 保存自動格式化: Java:Java -> Editor -> Save Actions,選中 Per ...
- 最近用到mysql和mybatis结合常用的知识点坐下整理
1.当用到集合in(x,x...)参数可以单个或者多个 ,当为单个时: findbyIds(List<Long> ids),或者findByids(Long [] ids) <se ...
- Leetcode-37-Sudoku Solver(Hard)
此处先留空 使用搜索和回溯,递归来实现 参考:http://blog.csdn.net/zxzxy1988/article/details/8586289 描述简介,代码量最少
- Python操作redis、memcache和ORM框架_Day13
一.memcache Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速 ...
- [MFC美化] SkinSharp使用详解2-SkinH.h函数介绍
SkinSharp功能强大,该皮肤库支持完全多种颜色改变等. 下面是静态链接库时的SkinH.h头文件: /*在Stdafx.h文件中加入如下语句 #include "SkinH.h&quo ...