我现在想在我的验证码中让5组数字随机生成的不同颜色,请问高手该如何实现!
解决方案 »
- winform程序里,调用页面上的一个js方法,如何取到这个js的返回值?么
- C# 为什么不能让 所有的对象自动回收它所使用的内存or资源
- 各位高人,xml里我想他做数据源绑定,并且有条件地,比如“id=1”怎么写?高手帮忙!
- 求一条SQL语句,急
- 请问一下各位高手,像类是新浪等大型网站是用什么技术开发制作的?
- 如何设置一组RadioButton的Tab键顺序?(急)
- 如何将一个从数据库中查询出的数字值绑定到Label?
- 外网端口映射访问内网asp.net mvc程序的问题,高分求
- 使用 this.webBrowser1.Dispose();后,登录的session丢失,该如何解决呢
- 关于建立表
- c#如何实现图片格式转换
- RaftingContainer这个东西是不是在2005去掉了?
每次绘制时用随机函数随机生成一种颜色(譬如生成1-10个数字,1代表红色,2代表绿色....)
=======================================
枚举Pens就可以了,不用自己定义。
web.config<configuration>
……
<system.web>
<database>
<add key="strConn" value="server=.;database=T37_estar;uid=sa;pwd=" />
</database>
</system.web>
……
</configuration>Global.asax.csprotected void Session_End(Object sender, EventArgs e)
{ Application.Lock();
Application.Remove(Session.SessionID.ToString());
Application["OL_UserCount"]=(int)Application["OL_UserCount"]-1;
Application.UnLock();
}
登陆的前台
login.aspx<table class="logintable"><tr> <td colspan="2" class="tdcaption"><font class="fcaption">ログイン</font></td></tr>
<tr> <td><font class="font100">ユーザーID:</font></td></tr>
<td><asp:TextBox CssClass="itxt" ID="txtName" Runat="server"></asp:TextBox></td></tr>
<tr> <td><font class="font100">パスワード:</font></td>
<td><asp:TextBox CssClass="itxt" ID="txtPwd" TextMode="Password" Runat="server"></asp:TextBox></td></tr>
<tr> <td><asp:Button CssClass="ibutton" ID="btnSubmit" Text="login" Runat="server"></asp:Button></td>
<td><input type="reset" class="ibutton" name="btnReset" value="reset"></td></tr>
</table>
login.aspx.cs
using System.Collections.Specialized;
using System.Data.SqlClient;
public void LoginBySQL()
{
string strConn=(String) ((NameValueCollection) Context.GetConfig("system.web/database"))["strConn"];
using (SqlConnection conn = new SqlConnection(strConn))
{ SqlCommand cmd = new SqlCommand("sp_IDPWD",conn);
cmd.CommandType=CommandType.StoredProcedure; //这里采用存储过程
cmd.Parameters.Add("@ID",SqlDbType.VarChar,20);
cmd.Parameters.Add("@PWD",SqlDbType.VarChar,20);
cmd.Parameters["@ID"].Value=txtName.Text;
cmd.Parameters["@PWD"].Value=txtPwd.Text;
conn.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if(dr.Read())
{
bool NotOL=true;
for(int i=0;i<Application.Count;i++)
{
if(Application[Application.GetKey(i).ToString()].ToString()==dr["UserID"].ToString())
NotOL=false;
}
if(NotOL)
{
Application[Session.SessionID.ToString()]=dr["UserID"].ToString();
Application["OL_UserCount"]=(int)Application["OL_UserCount"]+1;
Session["UserName"]=dr["UserName"].ToString();//Sessions
Response.Redirect("./main/main.aspx");
} else
message.Text="已经登陆";
}
else
{
message.Text="密码错误";
}
}
}
}
存储过程
ALTER PROCEDURE dbo.sp_IDPWD
(
@id varchar(20),
@pwd varchar(20)
/*@pwd datatype OUTPUT*/
)
AS
SET NOCOUNT ON
select * from [DB].[DB].[Admin] where (UserID=@id) and ([Password]=@pwd)
RETURN