求助asp.net用户名密码验证码-验证修改
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> <title>复杂验证码</title>
<script type="text/javascript">
function ShowValidImage() {
var numkey = Math.random();
document.getElementById("imgRandom").src = "/ValidCode.aspx?NumKey="+numkey;
} </script>
<style type="text/css"> .style1
{ width: 408px; }
</style></head><body>
<form id="form1" runat="server">
<div> </div>
<asp:Panel ID="Panel1" runat="server" Height="131px">
<table class="style1" align="center"
style="border: thin solid #66CCFF; height: 131px;">
<tr> <td align="right" >
<asp:Label ID="UseN" runat="server" Text="用户名:"></asp:Label>
</td><td>
<asp:TextBox ID="Textuse" runat="server" Width="143px" Height="26px"></asp:TextBox>
</td></tr> <tr>
<td align="right" >
<asp:Label ID="UseP" runat="server" Text="密 码:"></asp:Label>
</td> <td>
<asp:TextBox ID="Textpwd" runat="server" Width="144px" Height="24px"></asp:TextBox>
</td></tr> <tr> <td align="right">
<asp:Label ID="UseY" runat="server" Text="验证码:"></asp:Label>
</td> <td>
<asp:TextBox ID="Textyzm" runat="server" Width="146px" Height="24px"></asp:TextBox>
<img id="imgRandom" alt="看不清?点击更换" onclick="ShowValidImage()" src="ValidCode.aspx" title="看不清?点击更换" /></td> </tr><tr>
<td colspan=2 align=center>
<asp:Button ID="LoginBtn" runat="server" onclick="LoginBtn_Click" Text="登 录" />
</td></tr> </table> </asp:Panel></form> </body></html>
ValidCode.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ValidCode.aspx.cs" Inherits="ComplexValide.ValidCode" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>Untitled Page</title>
</head><body><form id="form1" runat="server">
<div></div></form></body></html>
ValidCode.aspx.cs
using System;
using System.Data;
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;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing;
namespace ComplexValide
{ public partial class ValidCode : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
Random rd = new Random();
string str = "ABCDEFGHIJKLMNOPQRSTURWXYZ0123456789复杂验证源码";
string my51aspx = "";
for (int i = 0; i < 6; i++)
{ my51aspx = my51aspx + str.Substring(rd.Next(42), 1); }
Session["Valid"] = my51aspx;
string bgFilePath = Server.MapPath(".\\images\\bg" + new Random().Next(5) + ".jpg");
System.Drawing.Image imgObj = System.Drawing.Image.FromFile(bgFilePath);
Bitmap newBitmap = new Bitmap(imgObj, 290, 80);
Graphics g = Graphics.FromImage(newBitmap);
SolidBrush brush = new SolidBrush(Color.Black);
String[] fontFamily ={ "Arial", "Verdana", "Comic Sans MS", "Impact", "Haettenschweiler", "Lucida Sans Unicode", "Garamond", "Courier New", "Book Antiqua", "Arial Narrow" };
for (int a = 0; a < my51aspx.Length; a++)
{ Font textFont = new Font(fontFamily[rd.Next(9)], 30, FontStyle.Bold);
g.DrawString(my51aspx.Substring(a, 1), textFont, brush, 40 + a * 36, 20); }
newBitmap.Save(Response.OutputStream, ImageFormat.Gif);
} } }
sql数据库aaa表userId(aa,bb,cc),pwd(11,22,33),RoleId(1,2,3)
用户输入正确的用户名、密码、验证码才能登录,且RoleId为1时登录a.aspx,为2时登录b.aspx,为3时登录c.aspx
请大家帮助修改代码!非常感谢!!!