submit
前台<body>中的代码:
<body>
<div id="top"> </div>
<form id="login" name="login" action="?Action=Login" method="post">
<div id="center">
<div id="center_left"></div>
<div id="center_middle">
<div class="user">
<label>用户名:
<input type="text" name="UserName" id="UserName" />
</label>
</div>
<br />
<div class="user">
<label>密 码:
<input type="password" name="UserPassword" id="UserPassword" />
</label>
</div>
</div>
<div id="center_middle_right"></div>
<div id="center_submit">
<div class="button"> <img alt="" id="loginin" src="data:images/dl.gif" width="57" height="20" onclick="document.login.submit()"/> </div>
<div class="button"> <img alt="" id="loginreset" src="data:images/cz.gif" width="57" height="20" onclick="document.login.reset()"/> </div>
</div>
<div id="center_right"></div>
</div>
</form>
<div id="footer"></div>
</body>
通过图片的点击事件,执行form.submit()传递form中的参数。
后台cs代码:
protected string Action = "";
myBaseClass myData = new myBaseClass();
protected class UserLoginInfo
{
public string UserName = "";
public string UserPassword = "";
}
protected UserLoginInfo _UserLoginInfo = new UserLoginInfo();//创建对象 protected void Page_Load(object sender, EventArgs e)
{
Init_WebControls();
} public void Init_WebControls()
{
try
{
if (!string.IsNullOrEmpty(Request.QueryString["Action"]))//获取form的Action中的参数
{
Action = Request.QueryString["Action"].Trim().ToLower();//去掉空格并变小写
前台<body>中的代码:
<body>
<div id="top"> </div>
<form id="login" name="login" action="?Action=Login" method="post">
<div id="center">
<div id="center_left"></div>
<div id="center_middle">
<div class="user">
<label>用户名:
<input type="text" name="UserName" id="UserName" />
</label>
</div>
<br />
<div class="user">
<label>密 码:
<input type="password" name="UserPassword" id="UserPassword" />
</label>
</div>
</div>
<div id="center_middle_right"></div>
<div id="center_submit">
<div class="button"> <img alt="" id="loginin" src="data:images/dl.gif" width="57" height="20" onclick="document.login.submit()"/> </div>
<div class="button"> <img alt="" id="loginreset" src="data:images/cz.gif" width="57" height="20" onclick="document.login.reset()"/> </div>
</div>
<div id="center_right"></div>
</div>
</form>
<div id="footer"></div>
</body>
通过图片的点击事件,执行form.submit()传递form中的参数。
后台cs代码:
protected string Action = "";
myBaseClass myData = new myBaseClass();
protected class UserLoginInfo
{
public string UserName = "";
public string UserPassword = "";
}
protected UserLoginInfo _UserLoginInfo = new UserLoginInfo();//创建对象 protected void Page_Load(object sender, EventArgs e)
{
Init_WebControls();
} public void Init_WebControls()
{
try
{
if (!string.IsNullOrEmpty(Request.QueryString["Action"]))//获取form的Action中的参数
{
Action = Request.QueryString["Action"].Trim().ToLower();//去掉空格并变小写
}
switch (Action)
{
case "login":
if (!string.IsNullOrEmpty(Request.Form["UserName"]) && !string.IsNullOrEmpty(Request.Form["UserPassWord"]))//获取form中的参数
{
_UserLoginInfo.UserName = Request.Form["UserName"].ToString();
_UserLoginInfo.UserPassword = Request.Form["UserPassWord"].ToString();
string user = "select 管理员名称,密码 from T_管理员表 where 管理员名称='" + _UserLoginInfo.UserName + "' and 密码='" + _UserLoginInfo.UserPassword + "'";
if (myData.readDataSet(user).Tables[0].Rows.Count == 1)
{
Response.Redirect("Main.aspx", false);//防止Response.End 方法终止页的执行
}
else
{
Response.Write("<Script Language=JavaScript>alert('密码或用户名错误,请重试!');</Script>"); }
}
break;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
} }
switch (Action)
{
case "login":
if (!string.IsNullOrEmpty(Request.Form["UserName"]) && !string.IsNullOrEmpty(Request.Form["UserPassWord"]))//获取form中的参数
{
_UserLoginInfo.UserName = Request.Form["UserName"].ToString();
_UserLoginInfo.UserPassword = Request.Form["UserPassWord"].ToString();
string user = "select 管理员名称,密码 from T_管理员表 where 管理员名称='" + _UserLoginInfo.UserName + "' and 密码='" + _UserLoginInfo.UserPassword + "'";
if (myData.readDataSet(user).Tables[0].Rows.Count == 1)
{
Response.Redirect("Main.aspx", false);//防止Response.End 方法终止页的执行
}
else
{
Response.Write("<Script Language=JavaScript>alert('密码或用户名错误,请重试!');</Script>"); }
}
break;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
submit的更多相关文章
- submit text3常用快捷键
在网上找了一些submit text的快捷键: Ctrl+D 选词 (反复按快捷键,即可继续向下同时选中下一个相同的文本进行同时编辑)Ctrl+G 跳转到相应的行Ctrl+J 合并行(已选择需要合并的 ...
- jquery 通过submit()方法 提交表单示例
jquery 通过submit()方法 提交表单示例: 本示例:以用户注册作为例子.使用jquery中的submit()方法实现表单提交. 注:本示例仅提供了对表单的验证,本例只用选用了三个字段作为测 ...
- ABAP关键字SUBMIT的简单例子和学习小记
网上有关SUBMIT实现程序调用的例子稍显复杂,而相关的参考和解释则不是很完善.本文给出一个SUBMIT的小示例程序(代码见文末),实现了最简单的程序间调用及返回值,以及SAP官方文档中相关内容的翻译 ...
- 表单元素的submit()方法和onsubmit事件
1.表单元素中出现了name="submit"的元素 2.elemForm.submit();不会触发表单的onsubmit事件 3.动态创建表单时遇到的问题 表单元素拥有subm ...
- jquery.validate不用submit而用js提交的例子
$("#form").validate(); $("#btn).click(function(){ if($("#form").valid()){ $ ...
- from表单如果未指定action,submit提交时候会执行当前url
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- ExecutorService中submit()和execute()的区别
在使用java.util.concurrent下关于线程池一些类的时候,相信很多人和我一样,总是分不清submit()和execute()的区别,今天从源码方面分析总结一下. 通常,我们通过Execu ...
- 关于click和submit的笔记
click主要用于元素的点击时的响应事件,而submit是指表单元素form的提交事件. 但是,当click加入到表单的提交按钮时,事情似乎就有点复杂,总是忘记了.这两天搜了下,又实践了一下. 主要用 ...
- 关于在用curl函数post网页数据时,遇上表单提交 type为submit 类型而且没有name和id时可能遇到的问题及其解决方法
curl函数库实现爬网页内容的链接在 http://www.cnblogs.com/linguanh/p/4292316.html 下面这个是没有name和id 标识的 <input type= ...
- ABAP程序互调用:SUBMIT、CALL TRANSACTION、LEAVE TO TRANSACTION
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
随机推荐
- js获取屏幕大小
1.js获取屏幕大小 <html> <script> function a(){ document.write( "屏幕分辨率为:"+screen.widt ...
- SQL常用语句总结
-------查询一个表有多少列select count(*) from sysobjects a join syscolumns bon a.id=b.idwhere a.name='XXX' -- ...
- Ohana Cleans Up
Ohana Cleans Up Description Ohana Matsumae is trying to clean a room, which is divided up into an n ...
- Unix NetWork Programming -- 环境搭建(Ubuntu 12.04 x86_64)
1. 下载源代码:http://www.ituring.com.cn/book/download/60498ad9-ede6-4023-a92b-04d47be23578 2. 解压文件后进入文件根目 ...
- 格式与布局 CSS阴影效果(Box-shadow)用法
一.position:fixed 锁定位置(相对于浏览器的位置),例如有些网站的右下角的弹出窗口. 二.position:absolute 1.外层没有position:absolute(或relat ...
- django1.9 创建数据表
1.在setting.py 中注册app: 2.编写models.py 文件创建表结构: (生成的表默认是: app名称_定义的表面 ) 3.执行命令: python manage.py check ...
- Spark cache 和 persist
1)RDD的cache()方法其实调用的就是persist方法,缓存策略均为MEMORY_ONLY:2)可以通过persist方法手工设定StorageLevel来满足工程需要的存储级别:3)cach ...
- Hibernate HQL的update方法详解
虽然hibernate提供了许多方法对数据库进行更新,但是这的确不能满足开发需要.现在讲解一下用hql语句对数据进行更新. 不使用参数绑定格式String hql="update User ...
- C++中嵌入Lua脚本环境搭建
第一步(环境准备工作): 工具: ●LuaForWindows_v5.1.4-46.exe傻瓜式安装. 作用:此工具可以在windows环境下编译运行Lua脚本程序.安装完成后会有两个图标:Lua和S ...
- Mysql日期时间大全
MySQL日期时间函数大全 DAYOFWEEK(date) 返回日期date是星期几(1=星期天,2=星期一,--7=星期六,ODBC标准)mysql> select DAYOFWEEK('1 ...