asp.net密码修改页面模板
发布网友
发布时间:2022-04-25 07:34
我来回答
共3个回答
热心网友
时间:2022-04-25 09:03
aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PassWordChangeUserForm.aspx.cs" Inherits="PassWordChangeUserForm" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link href="css/main.css" type="text/css" rel="stylesheet"/>
<script language="javascript" src="js/passwordStrength.js" type="text/javascript" charset="gb2312"></script>
<link type="text/css" rel="stylesheet" href="css/XCheck3.css" charset="gb2312"/>
<script language="javascript" type="text/javascript" src="js/XCheck3.js" charset="gb2312"></script>
<script language="javascript" type="text/javascript">
function checkPwd(args)
{
var oldPwd=document.getElementById("<%=hfPwd.ClientID %>").value;
if(args.value==oldPwd)
{
document.getElementById("validTxtOldPassWord").style.backgroundColor="#E9FFEB";
document.getElementById("validTxtOldPassWord").style.color="#1E7ACE";
document.getElementById("validTxtOldPassWord").innerHTML="原密码验证通过";
args.IsValid=true;
flag=true;
}
else
{
document.getElementById("validTxtOldPassWord").style.backgroundColor="#FFF2E9";
document.getElementById("validTxtOldPassWord").style.color="Red";
document.getElementById("validTxtOldPassWord").innerHTML="*不可为空或输入有误";
args.IsValid=false;
flag=false;
}
}
</script>
</head>
<script src="../Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<SCRIPT language="JavaScript" type="text/javascript" src="js/calendar.js"></SCRIPT>
<body bottommargin="0" leftmargin="0" topmargin="0" rightmargin="0">
<form runat="server" id="fm1">
<br>
<%--<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center"
border="0">
<tr>
<th colspan="3" style="height: 25px">
密码修改</th>
</tr>
<tr>
<td class="usertablerow2" align="right" style="width: 300px; height: 26px;">
原密码:</td>
<td class="usertablerow2" style="height: 26px">
<input id="txtOldPassWord" type="password" runat="server" style="width:200px;" onblur="return checkPwd(this)" />
</td>
</tr>
<tr>
<td class="usertablerow2" align="right" style="width: 300px; height: 26px;">
新密码:
</td>
<td class="usertablerow2" style="height: 26px">
<input id="txtPassWord" type="password" runat="server" style="width:200px;" onkeyup="ps.update(this.value);" />
</td>
</tr>
<tr>
<td class="usertablerow2" align="right" style="width: 300px">
密码确认:
</td>
<td class="usertablerow2">
</td>
</tr>
<tr>
<td align="center" class="usertablerow1" colspan="2">
<asp:Button ID="Button1" runat="server" CssClass="ptsbutton" OnClick="Button1_Click"
Text=" 更 新 " />
<input type="Button" Class="ptsbutton" value=" 返 回 " OnClick="javascript:history.go(-1);" /><div id="Div2">
</div> </td>
</tr>
<tr>
<td colspan="2">
<asp:HiddenField ID="hfPwd" runat="server" />
</td>
</tr>
</table>--%>
<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center"
border="0">
<tr >
<td class="usertablerow2" style="width:200px; text-align:right;">
原密码
</td>
<td class="usertablerow2" style=" width:200px; vertical-align:middle; text-align:left;">
<input id="txtOldPassWord" type="password" runat="server" style="width:200px; height:23px;" onblur="return checkPwd(this)" />
</td>
<td class="usertablerow2" style="width:250px; text-align:left;" >
<font size="2" color="Red"> <asp:Label ID="validTxtOldPassWord" runat="server" BorderWidth="0">*原密码必须填写</asp:Label></font>
</td>
</tr>
<tr >
<td class="usertablerow2" style="width:200px; text-align:right;">
新密码
<td class="usertablerow2" >
<input id="txtPassWord" type="password" runat="server" style="width:200px; height:23px;" onkeyup="ps.update(this.value);" />
</td>
<td class="usertablerow2" style="width:250px;text-align:left;" >
<asp:Label ID="validTxtPassWord" runat="server" BorderWidth="0"></asp:Label>
</td>
</tr>
<tr>
<td class="usertablerow2"> </td>
<td class="usertablerow2">
<script type="text/javascript" language="javascript">
var ps = new PasswordStrength();
ps.setSize("200","20");
ps.setMinLength(6);
</script>
</td>
<td class="usertablerow2"> </td>
</tr>
<tr >
<td class="usertablerow2" style="text-align:right; width:200px;">
密码确认
<td class="usertablerow2">
<asp:TextBox ID="txtAssurePassword" TextMode="Password" runat="server" style="width:200px; height:23px;"></asp:TextBox></td>
<td class="usertablerow2" style="width:250px; text-align:left;" >
<asp:Label ID="validTxtAssurePassword" runat="server" BorderWidth="0"></asp:Label>
</td>
</tr>
<tr style="text-align:center;">
<td class="usertablerow2" colspan="3" rowspan="2" style="text-align: center">
<asp:Button ID="Button1" runat="server" Width="66px" Text=" 提 交 " OnClientClick="return formok()" OnClick="Button1_Click" />
<input id="Button3" type="button" value=" 取 消 " style="width: 66px" />
</td>
</tr>
<tr>
</tr>
</table>
<br>
<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center"
border="0">
<tr>
<th colspan="2">
使用方法
<asp:HiddenField ID="hfPwd" runat="server" />
</th>
</tr>
<tr>
<td class="usertablerow1" align="right" width="11%">
<strong>特殊说明</strong></td>
<td class="usertablerow1" width="89%">
按照要求输入即可
</td>
</tr>
</table>
</form>
<script type="text/javascript">
//基础方法
function $(objid){
return document.getElementById(objid);
}
var arr=new Array();
////////////////////////////
/*
方法介绍
1-XChecksetcont();有五个参数,分别是
(1)提示信息
(2)输入正确提示
(3)输入错误提示
?(4)数据库存在此数据输出的提示信息。不存在Ajax检查的字段此地方写“”。或者null(建议null)
(5)提交表单还有字段为成功系统的提示信息,是以alert的形式提示。
2-check()
参数分别是输入控件的id,。显示提示语句的id。检测此字段的方法名称。是否启用ajax检查。
3-seturl。可选,。不启用ajax检测唯一性或者验证码的时候不必写此方法
指定一个jsp页面,例如***.jsp,接受参数可以指定名称,例子中是uname
你需要编写一个***.jsp,次页面没有htm代码,全部是java代码,接受一个uname的参数
然后判断uname是否存在于数据库,存在,out.print("0")。不存在out.print("1")
*/
//arr[0]=new XCheck();
//arr[0].XChecksetcont("中文或英文名称","验证通过","不可为空或格式错误","","用户名填写错误");
//arr[0].check("txtUserName","validTxtUserName","checknicks",false);
///////////////////////////////
arr[0]=new XCheck();
arr[0].XChecksetcont("6-20长度","验证通过","不可为空或格式错误");
arr[0].check("txtPassWord","validTxtPassWord","chkpass",false);
//////////////
arr[1]=new XCheck();
arr[1].XChecksetcont("密码确认","验证通过","两次密码输入不同");
arr[1].check("txtAssurePassword","validTxtAssurePassword","chkapass",false);
function formok()
{
if(flag==false)
{
alert("原密码输入错误");
document.getElementById("txtOldPassWord").focus();
return false;
}
for(var i=0;i<arr.length;i++)
{
if(!arr[i].getstate())
{
arr[i].alertwrong();
return false
}
}
// if(!chkapass($("txtPassWord").value))
//{arr[6].alertwrong();
//return false;
//}
return true;
}
///////////////////////////////////
function checknick(str) {
var re=/[^0-9a-zA-Z\_]/ ;
if(re.test(str)) {
// alert("你输入了非法字符!");
return false;
}
if(str.length>12 || str.length<3)
{ // alert("error!");
return false;
}
return true;
}
///////////////////////////////////
function checknicks(str)
{
reg = /^([\u4E00-\u9FA5]|[A-Za-z])*$/;
if(reg.test(str) && str!=null && str!="")
{
return true;
}
else
{
return false;
}
}
function chkpass(val)
{
if(val.length>=6 && val.length<=20)
return true;
else
return false;
}
function chkemail(val)
{
var remail=/^\w+([-+.]\w+)*@\w+([-.]\\w+)*\.\w+([-.]\w+)*$/;
if(remail.test(val))
{
return true;
}
return false;
}
function chkmob(val)
{
//if(val==null || val==""|| val.length>11){
//return false;
//}
//var remob= /^((\(\d{3}\))|(\d{3}\-))?13\d{9}|15[089]\d{8}$/ ;
//if( remob.test(val) ){
//return true;
//}else{
//return false;
//}
//}
//function chkqq(val)
//{
//if(val==null || val==""){
//return true;
//}
//var reqq= /^[1-9]\d{4,9}$/ ;
//if( reqq.test(val) ){
//return true;
//}else{
//return false;
//}
var i,j,strTemp;
strTemp="0123456789-()# ";
var reg0=/^13\d{5,9}$/; //130--139。至少7位
var reg1=/^153\d{8}$/; //联通153。至少7位
var reg2=/^159\d{8}$/; //移动159。至少7位
var reg3=/^158\d{8}$/;
var reg4=/^150\d{8}$/;
var reg5=/^151\d{8}$/;
if(val==""||val==null)
{
return false;
}
if (reg0.test(val)||reg1.test(val)||reg2.test(val)||reg3.test(val)||reg4.test(val)||reg5.test(val))
{
return true;
}
for (i=0;i<val.length;i++)
{
j=strTemp.indexOf(val.charAt(i));
if (j==-1)
{
//说明有字符不合法
return false;
}
}
//说明合法
return true;
}
function chknull(val)
{
if(val==null || val==""){
return false;
}
else{
return true;
}
}
function chkapass(val)
{
if($("txtPassWord").value==val)
return true;
else
return false;
}
</script>
</body>
</html>
------------------------------------
.cs:
using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class PassWordChangeUserForm : System.Web.UI.Page
{
Model.Authority nc_Users = new Model.Authority();
BLL.Authority bll_Users = new BLL.Authority();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
int IdNum = int.Parse(SessionInclude.Id);
nc_Users = bll_Users.GetModel(IdNum);
hfPwd.Value = nc_Users.PassWord;
}
protected void Button1_Click(object sender, EventArgs e)
{
nc_Users.PassWord = txtPassWord.Value;
bll_Users.Update(nc_Users);
if (SessionInclude.SessionId != "管理员")
{
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DB"].ConnectionString);
Model.SalePerson MSP = new BLL.SalePerson().GetPageList(1, 1, "id", false, "userName='" + SessionInclude.SessionId + "'")[0];
MSP.password = txtPassWord.Value;
BLL.SalePerson BSP = new BLL.SalePerson();
BSP.Update(MSP);
MessageBox.Show("密码更新成功!", "userMainPage.aspx");
}
else
{
MessageBox.Show("密码更新成功!", "adminMainPage.aspx");
}
}
}
这是我的一个项目中的密码修改前台和后台代码,供你参考,如果感觉对你有用请鼓励下!!!
热心网友
时间:2022-04-25 10:21
修改密码页面。不就输入原密码。
然后重新输入新密码两次吗?
这个模板就按照这样说的就可以啦。然后加以点修饰的词。解决用户的体验,
框架上加入您网站的头部和底部。就OK拉
热心网友
时间:2022-04-25 11:56
sql基本语句。Update