===第一种===================================================================================================
<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"不共存
只能在后台加验证(服务端向客户端注册脚本块)
================================================================================================================
随机推荐
- Android ListView多布局讲解
Listview优化是一个老生常谈的事情了,其优化的方面也有很多种,例如,布局重用.在getView()中减少逻辑计算.减少在页面滑动的时候加在图片,而是在页面停止滚动的时候再加在图片.而今天要介绍的 ...
- java基础知识拾遗(二)
1.finally public static int func (){ try{ return 1; }catch (Exception e){ return 2; }finally { retur ...
- Ionic的项目结构-工程目录
做前端的都应该知道一个框架 Ionic 这个是移动端webAPP最好用的吧(个人认为),那今天就来说说这个项目的结构以及文件的含义,希望对大家有所帮助 想看如何生成文件的话详细看我上篇博客 在用编 ...
- Windows设置VMware开机自动启动,虚拟机也启动
很多用windows系统电脑开发的童鞋,会在自己电脑上装一个虚拟机,然后在装一个linux系统当作服务器来使用.但每次电脑开机都要去重启一下虚拟机电源,实在是不划算.下面博主教大家在windows系统 ...
- DB2表是否存在
select count(1) from syscat.tables where tabname='T1';
- hdu 1890 Robotic Sort(splay 区间反转+删点)
题目链接:hdu 1890 Robotic Sort 题意: 给你n个数,每次找到第i小的数的位置,然后输出这个位置,然后将这个位置前面的数翻转一下,然后删除这个数,这样执行n次. 题解: 典型的sp ...
- magento获取ip地址
Mage::helper('coreservice')->getRequestIp()获取IP地址
- java-并发解决方案
并发产生数据不一致的原因:1.程序共享对象:2.多线程.3.基于1和2,取出来的数据可能不是最新的. 解决方案:只要是原子性操作,就不会出现问题.原子性操作,代表cpu会一直执行这个操作,知道结束. ...
- MVC-工作原理
ASP.NET MVC的原理,其实就是使用HttpModule和HttpHandler将用户的请求拦截,按照设定的路由规则解释到相应的控制器和Action,加以执行.Module是一个比较宏观一点的概 ...
- LeetCode 392. Is Subsequence
Given a string s and a string t, check if s is subsequence of t. You may assume that there is only l ...