以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 未将对象引用设置到对象的实例。 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=119029) |
-- 作者:zhy400137 -- 发布时间:2018/5/16 13:46:00 -- 未将对象引用设置到对象的实例。 下面这段代码,正常按顺序可以执行,不报错,但只要在加载的页面点击刷新,就会出现未将对象引用设置到对象的实例。 想了很久不清楚原因,请教,谢谢 Dim e As RequestEventArgs = args(0) Dim wb As New weui If e.PostValues.ContainsKey("isgoodsquery") Then msgbox(1) If e.PostValues.ContainsKey("部门名称") AndAlso e.PostValues.ContainsKey("提交时间") AndAlso e.PostValues.ContainsKey("系列分类") Then Dim cmd As New SQLCommand cmd.ConnectionName = DataSource \'记得设置数据源名称 cmd.CommandText = "S elect * From {图片列表} w here 系列分类=\'" & e.PostValues("系列分类") & "\'" Dim dt As DataTable = cmd.ExecuteReader If dt.DataRows.count>0 Then wb.AddForm("","form1","goodslist.htm") With wb.AddInputGroup("form1","ipg1","图片列表") With .AddInput("部门名称","部门名称","text") .value = e.PostValues("部门名称") .Readonly=True End With With .AddInput("提交时间","提交时间","date") .value = e.PostValues("提交时间") .Readonly=True End With With .AddInput("系列分类","系列分类","text") .value = e.PostValues("系列分类") .Readonly=True End With For Each dr As DataRow In dt.DataRows With wb.AddPanelGroup("",dr("_Identify"),"产品信息") .Add(dr("_Identify"),dr("图片编码"),dr("系列分类") & "," & dr("设计编码") & "," & dr("产地") & ",价格:" & dr("零售价"),"./images/" & dr("文件夹名称") & "/" & dr("图片名称"),"http://192.168.1.113/goodsqtn.htm?goodsid=" & dr("_Identify") & "&depname=" & e.PostValues("部门名称") & "&series=" & e.PostValues("系列分类") & "&submittime=" & e.PostValues("提交时间")) \'超链接 End With Next End With With wb.AddDialog("","dlg1", "","") .AddButton("btnOK","确定") End With wb.AppendHTML("<script src=\'./lib/jquery.min.js\'></script>") \'引入脚本文件 wb.AppendHTML("<div id=\'goodsqtnlist\' style=\'margin:0.5em\'></div>") \'插入一个div,用于显示服务器返回的页面 wb.AppendHTML("<script src=\'./lib/goodslistreturn.js\'></script>") \'引入脚本文件 wb.AppendHTML("<script src=\'./lib/photozoom.js\'></script>") \'引入脚本文件 End If Else wb.InsertHTML("请按输入部门名称,提交时间,系列分类!") End If End If e.WriteString(wb.Build) 在红色的地方加入了msgbox进行调试,正常进入时,会弹出1,但刷新出错时,不弹出1
|
-- 作者:zhy400137 -- 发布时间:2018/5/16 13:53:00 -- 刷新时,网页会提示“此网页已被重定向到新地址,您要将您输入的数据发送到新的地址吗?”的提示,点击确实就会出现错误 |
-- 作者:有点甜 -- 发布时间:2018/5/16 14:16:00 -- 以下是引用zhy400137在2018/5/16 13:53:00的发言:
刷新时,网页会提示“此网页已被重定向到新地址,您要将您输入的数据发送到新的地址吗?”的提示,点击确实就会出现错误
1、如果msgbox没有弹出,说明不是你这段代码导致的错误;
2、请在httprequest加入msgbox调试出错位置,然后刷新网页测试。 |
-- 作者:zhy400137 -- 发布时间:2018/5/16 14:25:00 -- Dim fl As String = "d:\\test\\" & e.path If filesys.FileExists(fl) Dim idx As Integer = fl.LastIndexOf(".") Dim ext As String = fl.SubString(idx) Select Case ext Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar",".txt" e.WriteFile(fl) Return \'这里必须返回 End Select End If Dim wb As New weui \'身份验证 Dim Verified As Boolean \'用于标记用户是否通过了身份验证 Dim UserID As String = e.Cookies("userid") \'从cookie中获取用户名 Dim PassWord As String = e.Cookies("password") \'从cookie中获取用户密码 If e.Path = "login.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码 If e.PostValues.ContainsKey("userid") AndAlso e.PostValues.ContainsKey("password") Then UserID = e.PostValues("userid") PassWord = e.PostValues("password") End If End If msgbox(1) \'验证密码 Dim cmd As New SQLCommand Dim dt As DataTable Dim dr As DataRow cmd.ConnectionName = DataSource cmd.CommandText = "Selec t * F rom {用户管理} Where [用户编号] = \'" & UserID & "\'" dt = cmd.ExecuteReader If dt.DataRows.Count > 0 Then dr=dt.DataRows(0) If PassWord=DecryptText(dr("登录密码") ,"zhgg","11111") Then Verified = True End If End If msgbox(2) If Verified AndAlso e.Path = "login.htm" Then \'如果用户访问的是登录页,且身份验证成功 wb.AppendCookie("userid",UserID) \'将用户名和密码写入cookie wb.AppendCookie("password",PassWord) wb.AppendCookie("depname",dr("部门名称")) wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'直接跳转到首页 e.WriteString(wb.Build) \'生成网页 Return \'必须的 ElseIf Verified = False AndAlso e.Path <> "login.htm" Then \'如果用户身份验证失败,且访问的不是登录页面 wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'那么直接跳转到登录页面 e.WriteString(wb.Build) \'生成网页 Return \'必须的 End If msgbox(3) \'开始生成网页 Select Case e.path Case "login.htm" \'登录页面 Functions.Execute("Web_Login",e) Case "exit.htm" \'退出登录 Functions.Execute("Web_Exit",e) Case "", "default.htm" \'首页 Functions.Execute("Web_Default",e) Case "qtnlist.htm" Functions.Execute("Web_QtnList",e) Case "goodsquery.htm" Functions.Execute("Web_GoodsQuery",e) Case "goodslist.htm" Functions.Execute("Web_GoodsList",e) Case "goodsqtn.htm" Functions.Execute("Web_GoodsQtn",e) End Select e.WriteString(wb.Build) \'生成网页
|
-- 作者:zhy400137 -- 发布时间:2018/5/16 14:26:00 -- 加入了msgbox,刷新页面测试,发现错误时,1都没弹出来,但好像代码没啥问题? |
-- 作者:zhy400137 -- 发布时间:2018/5/16 14:27:00 -- 是先弹出的错误,“未将。。。。”,然后所有的msgbox都正常弹出了 |
-- 作者:有点甜 -- 发布时间:2018/5/16 14:33:00 -- 1、msgbox,请写在最顶层以及合适的位置测试,既然msgbox没有弹出,那说明在之前就有错了;
2、你httprequest事件最后的代码【e.WriteString(wb.Build) \'生成网页】请删除掉。 |
-- 作者:zhy400137 -- 发布时间:2018/5/16 14:39:00 -- 第2点处理了,但错误依然有,也不清楚哪来的,点错误详细也没有啥提示 |
-- 作者:有点甜 -- 发布时间:2018/5/16 14:42:00 -- msgbox,请写在最顶部以及合适的位置测试,既然msgbox没有弹出,那说明在之前就有错了啊。
写到最上面去测试定位啊。 |
-- 作者:zhy400137 -- 发布时间:2018/5/16 14:48:00 -- msgbox(0.1) Dim fl As String = "d:\\test\\" & e.path msgbox(0.2) If filesys.FileExists(fl) Dim idx As Integer = fl.LastIndexOf(".") Dim ext As String = fl.SubString(idx) Select Case ext Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar",".txt" e.WriteFile(fl) Return \'这里必须返回 End Select End If msgbox(0.4) Dim wb As New weui msgbox(0.5) \'身份验证 Dim Verified As Boolean \'用于标记用户是否通过了身份验证 Dim UserID As String = e.Cookies("userid") \'从cookie中获取用户名 Dim PassWord As String = e.Cookies("password") \'从cookie中获取用户密码 If e.Path = "login.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码 If e.PostValues.ContainsKey("userid") AndAlso e.PostValues.ContainsKey("password") Then UserID = e.PostValues("userid") PassWord = e.PostValues("password") End If End If msgbox(1) \'验证密码 Dim cmd As New SQLCommand Dim dt As DataTable Dim dr As DataRow cmd.ConnectionName = DataSource cmd.CommandText = "Selec t * Fro m {用户管理} Where [用户编号] = \'" & UserID & "\'" dt = cmd.ExecuteReader If dt.DataRows.Count > 0 Then dr=dt.DataRows(0) If PassWord=DecryptText(dr("登录密码") ,"zhgg","1111111") Then Verified = True End If End If msgbox(2) If Verified AndAlso e.Path = "login.htm" Then \'如果用户访问的是登录页,且身份验证成功 wb.AppendCookie("userid",UserID) \'将用户名和密码写入cookie wb.AppendCookie("password",PassWord) wb.AppendCookie("depname",dr("部门名称")) wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'直接跳转到首页 e.WriteString(wb.Build) \'生成网页 Return \'必须的 ElseIf Verified = False AndAlso e.Path <> "login.htm" Then \'如果用户身份验证失败,且访问的不是登录页面 wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'那么直接跳转到登录页面 e.WriteString(wb.Build) \'生成网页 Return \'必须的 End If msgbox(3) \'开始生成网页 Select Case e.path Case "login.htm" \'登录页面 Functions.Execute("Web_Login",e) Case "exit.htm" \'退出登录 Functions.Execute("Web_Exit",e) Case "", "default.htm" \'首页 Functions.Execute("Web_Default",e) Case "qtnlist.htm" Functions.Execute("Web_QtnList",e) Case "goodsquery.htm" Functions.Execute("Web_GoodsQuery",e) Case "goodslist.htm" Functions.Execute("Web_GoodsList",e) Case "goodsqtn.htm" Functions.Execute("Web_GoodsQtn",e) End Select 应该不是这的错误吧,我MSGBOX都写到最顶点了,刷新网页会引发窗口事件? 现在是现弹出错误,才弹出0.1
|