ASPについてNET検証コード
7341 ワード
1 ValidateCode.ashx , 。。 。。。 。。。
2 Session["CheckCode"] 。。 。。 3 1. 4 :TextBox 5 : TextBox 6 :TextBox 7
8 <p>
9 :<asp:TextBox ID="txt" runat="server"></asp:TextBox>
10 <img alt=" " src="/ValidateCode.ashx" title=" , " onclick="Changeimg(this)" style="cursor:pointer" />
11
12 <script type="text/javascript"> //
13 function Changeimg(img) {
14 img.src = "ValidateCode.ashx?id=" + new Date();
15 }
16 </script>
17 </p>
18 2. URL , aspx
19 btnSubmit
20
21 protected void btnSubmit_Click(object sender, EventArgs e)
22 {
23 if (!string.IsNullOrEmpty(txtVerify.Text.Trim())) //
24 {
25 if (Session["CheckCode"].ToString().ToLower().Equals(txtVerify.Text.Trim())) //
26 {
27 //Response.Write("<script>alert(' ')</script>");
28 string _user = txtUser.Text.Trim();
29 string _pwd = txtPwd.Text.Trim();
30 string sql = string.Format("SELECT * FROM TREE WHERE City='{0}' AND ID='{1}'",_user,_pwd);
31 int result = new BStudentInfo().GetSutdentInfo(sql);//
32 if (result > 0)
33 {
34 Response.Redirect("TreeView.aspx"); // "TreeView.aspx"
35 }
36 }
37 else
38 {
39 Response.Write("<script>alert(' ')</script>");
40 }
41 }
42
43 }
。。 。。。。 。。 ~~