这是验证的方法using System; using System.Data; using System.Configuration; 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 _Default : System.Web.UI.Page { DB db = new DB(); CheckOther chk = new CheckOther(); BasePage bp = new BasePage(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string selectYear = "SELECT distinct sta_year FROM FundStateData where sta_year<>'' order by sta_year desc"; DataSet ds = db.dbSelect(selectYear); if (ds != null && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //if (db.IFHasRow("FundStateData", "sta_year", Convert.ToString(int.Parse(ds.Tables[0].Rows[i][0].ToString()) - 2)) == 1 && db.IFHasRow("FundStateData", "sta_year", Convert.ToString(int.Parse(ds.Tables[0].Rows[i][0].ToString()) - 1)) == 1) //{ this.Select1.Items.Add(ds.Tables[0].Rows[i][0].ToString()); if (ds.Tables[0].Rows[i][0].ToString() == DateTime.Now.Year.ToString()) { this.Select1.Value = DateTime.Now.Year.ToString(); } //} } } } }
<head runat="server">
<title></title>
<link href="Styles/StyleSheet.css" type="text/css" rel="stylesheet"/>
<style type="text/css">
}
body {
background-color: #41464C;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body leftmargin="0" topmargin="0" scroll="no" style="border:0px;">
<form id="form1" runat="server"> <table width="1000" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#040404" valign="middle">
<tr>
<td align="left" valign="middle">
<table width="1000" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td align="left">
<table width="100%" height="215" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td background="images/sino_01.gif"></td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="508" align="left"><img src="images/sino_02.gif" alt="logo" width="508" height="194" /></td>
<td width="314" align="left" valign="top"><table width="341" height="160" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="314" height="43" background="images/denglu_03.gif"> </td>
</tr>
<tr>
<td height="108" valign="bottom" background="images/denglu_05.gif"><table width="314" height="100" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="24%" rowspan="4"> </td>
<td width="76%" height="22"><span class="bt"> 用户名:</span>
<input id="UserID" type="text" runat="server" class="logins" maxlength="20" style="height:auto"/></td>
</tr>
<tr>
<td style="height: 22px"><span class="bt"> 密 码:</span>
<input id="Pwd" maxlength="20" type="password" runat="server" class="logins" style="height:auto" /></td>
</tr>
<tr>
<td height="22"><span class="bt">数据年份:</span>
<select id="Select1" style="width: 60px;height:auto" runat="server" name="select" class="logins">
</select> </td>
</tr>
<tr>
<td height="30" valign="bottom"> <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/sino_14.gif" OnClick="ImageButton1_Click1" />
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/Images/sino_16.gif"
OnClick="ImageButton2_Click1" /></td>
</tr>
</table></td>
</tr>
<tr>
<td height="43" background="images/denglu_06.gif"> </td>
</tr>
</table></td>
<td background="images/sino_04.gif"> </td>
</tr>
</table>
<table width="100%" height="214" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" background="images/sino_19.gif"><table width="350" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="23"></td>
</tr>
<tr>
<td height="60" align="center" valign="top">
<span class="text_A_w">版权所有© </span></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
string url = "receive.aspx?id="+txtId.Text+"&name="+txtName.Text+"";
Response.Redirect(url);在receive页面的地址栏就会显示
你要获取值的话就:request.QueryString["id"]...
using System.Data;
using System.Configuration;
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 _Default : System.Web.UI.Page
{
DB db = new DB();
CheckOther chk = new CheckOther();
BasePage bp = new BasePage(); protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string selectYear = "SELECT distinct sta_year FROM FundStateData where sta_year<>'' order by sta_year desc";
DataSet ds = db.dbSelect(selectYear);
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
//if (db.IFHasRow("FundStateData", "sta_year", Convert.ToString(int.Parse(ds.Tables[0].Rows[i][0].ToString()) - 2)) == 1 && db.IFHasRow("FundStateData", "sta_year", Convert.ToString(int.Parse(ds.Tables[0].Rows[i][0].ToString()) - 1)) == 1)
//{
this.Select1.Items.Add(ds.Tables[0].Rows[i][0].ToString());
if (ds.Tables[0].Rows[i][0].ToString() == DateTime.Now.Year.ToString())
{
this.Select1.Value = DateTime.Now.Year.ToString();
}
//}
}
}
}
}
protected void ImageButton1_Click1(object sender, ImageClickEventArgs e)
{
try
{
string userID = this.UserID.Value.ToString();
string password = this.Pwd.Value.ToString();
if (userID == "")
{
BasePage.MessageBox.Show("用户名不能为空!");
return;
}
if (password == "")
{
BasePage.MessageBox.Show("密码不能为空!");
return;
}
if (chk.CheckUserLogin(userID, password))
{
Session["Login"] = "Yes";
Session["UserID"] = userID;
//Session["id"] = "100000";
string selectName = "SELECT * FROM admin_user WHERE admin_name='" + userID + "'";
DataSet dsname = db.dbSelect(selectName);
Session["UserName"] = dsname.Tables[0].Rows[0]["admin_truename"].ToString();
Session["admin_login"] = dsname.Tables[0].Rows[0]["admin_name"].ToString();
Session["group_id"] = dsname.Tables[0].Rows[0]["group_id"].ToString();
Session["admin_id"] = dsname.Tables[0].Rows[0]["admin_id"].ToString();
System.Net.IPAddress addr = new System.Net.IPAddress(System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList[0].Address);
string upSql = string.Format("update admin_user set admin_lastlogin='{0}',admin_logins = admin_logins+1,admin_ip='{1}' where admin_name='{2}'", DateTime.Now, addr, userID);
db.dbExcuteCmdText(upSql);
Response.Redirect("Main.aspx", false);
int aaa;
aaa = int.Parse(this.Select1.Items[this.Select1.SelectedIndex].Text.ToString());
string insertYear = "UPDATE SetSysYear SET SysYear = '" + aaa.ToString() + "' ";
db.dbExcuteCmdText(insertYear);
return;
}
else
{
BasePage.MessageBox.Show("用户名或密码不正确!");
return;
}
}
catch (Exception ex)
{
BasePage.TurnError.Redirect(ex);
}
}
protected void ImageButton2_Click1(object sender, ImageClickEventArgs e)
{
this.UserID.Value = "";
this.Pwd.Value = "";
this.Select1.SelectedIndex = 0;
}
}
验证登陆之前输出一下看看
request.Params[".."]
其实LZ可以用session 没必要把参数用URL传递这样不安全
用户名和年份可以传过来 ,但是 密码不能传过来 ,不知道为啥 啊
{
if(!IsPostBack)
{
string uid=request["uid"].tostring().trim();
string pwd=request["pwd"].tostring().trim();
if(!checkLogin(uid,pwd))
response("Error.aspx");
}
}