mark验证码
Select Case e.Path
Case "login.htm"
Dim wb As New weui
wb.AddForm("","form1","login.htm")
With wb.AddInputGroup("form1","ipg1","登录")
If e.PostValues.ContainsKey("isj") AndAlso e.PostValues.ContainsKey("imm") Then '判断是否是验证失败后的重新登录
wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 '如果用户通过登录按钮访问,则给用户一个2秒的提示.
End If
With .AddInputCell("ic1") '通过InputCell增加输入框(1表示突出显示,2表示红色警示图标)
.AddLabel("lsj","手机",0) '增加标签(0显示在左边)
.AddInput("isj","text",1).PlaceHolder= "请输入手机号" '增加输入框(0靠左显示,1居中显示,2靠右显示)
End With
With .AddInputCell("ic2")
.AddLabel("lmm","密码",0)
.AddInput("imm","password",1).PlaceHolder= "请输入密码"
End With
With .AddInputCell("ic5") '通过InputCell增加输入框
.AddLabel("lyzm","验证码",0) '增加标签,0显示在左边
.AddInput("yzm","text",1) '增加输入框,1表示显示在中间
.AddImage("pim","/getVimg.htm",2).Attribute="onclick=""this.src = 'getVimg.htm?rand=' + Math.random() """ '增加一个图片,2比表示显示在右边
End With
'End With
.AddSwitch("jizhumima","记住密码")
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "登录", "","submit") '"/index.htm")
End With
With wb.AddButtonGroup("form1","btg2", False)
.Add("btn2", "免费注册","","/register.htm").Kind = 1
.Add("btn3", "忘记密码","","/getback.htm").Kind = 1
End With
End With
e.WriteString(wb.Build) '生成网页
Case "getVimg.htm"
Dim bmp As new bitmap(70, 40)
Dim g As Graphics = Graphics.FromImage(bmp)
Dim Val1 As Double = Rand.Next(10000)
Dim fnt As New Font("宋体",16)
Dim msg As String = format(val1, "0000")
g.DrawString(msg,fnt,Brushes.Red,10,10)
e.AppendCookie("yanzhengma", msg) '校对这个cookie
'bmp.Save(ProjectPath & "Images\temp.jpg")
'bmp.dispose
'e.WriteFile(ProjectPath & "Images\temp.jpg")
Dim ms As new IO.MemoryStream()
bmp.Save(ms, ImageFormat.png)
Dim buffer = ms.ToArray
e.Response.ContentType = "image/Png"
Dim output = e.response.OutputStream
output.Write(buffer,0,buffer.Length)
output.Close()
End Select
[此贴子已经被作者于2017/3/20 18:40:15编辑过]