帮助里的标准Weui框架代码是
HttpRequest:
'通用事件头,用于发送已经存在的常见文件
Dim fl As String = "d:\web\" & 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"
e.WriteFile(fl)
Return '这里必须返回
End Select
End If
'以下是动态生成网页的代码
Dim wb As New WeUI '定义一个基于weui框架的网页生成器
Select Case e.Path
Case "addnew.htm",""
wb.InsertHTML("这是默认页面addnew.htm")
Case "order.htm"
wb.InsertHTML("这是普通页面order.htm")
End Select
e.WriteString(wb.Build) '生成网页
---------------------------------------------------------------
由于我不想经常打开网络管理器(速度太慢),我这样写,可以吗
①HttpRequest:
'通用事件头,用于发送已经存在的常见文件
Functions.Execute("Web_GetBasic",e)
'以下是动态生成网页的代码
Dim wb As New WeUI '定义一个基于weui框架的网页生成器
Select Case e.Path
Case "addnew.htm",""
wb.InsertHTML("这是默认页面addnew.htm")
Case "order.htm"
wb.InsertHTML("这是普通页面order.htm")
End Select
e.WriteString(wb.Build) '生成网页
②内部函数Web_GetBasic:
Dim e As RequestEventArgs = args(0)
Dim fl As String = ProjectPath & "HYWeb\" & 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
---------------------------------------------------------------
再后来我觉得打开网络管理器修改生成网页代码也太麻烦,变成
①HttpRequest:
Functions.Execute("Web_Main",e)
②内部函数Web_Main:
Dim e As RequestEventArgs = Args(0)
Functions.Execute("Web_GetBasic",e) '通用事件,获取必要的文件如 css js 等
Dim wb As New weui '引用WeUi框架
'以下是动态生成网页的代码
Dim wb As New WeUI '定义一个基于weui框架的网页生成器
Select Case e.Path
Case "addnew.htm",""
wb.InsertHTML("这是默认页面addnew.htm")
Case "GetItemSmallClassName.htm"
Functions.Execute("Web_GetItemSmallClassName",e)
End Select
e.WriteString(wb.Build) '生成网页
③内部函数Web_GetBasic:
Dim e As RequestEventArgs = args(0)
Dim fl As String = ProjectPath & "HYWeb\" & 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
④内部函数Web_GetItemSmallClassName:
Dim e As RequestEventArgs = Args(0)
Dim pps As String = DataTables("商品档案").SQLGetComboListString("小类名称","大类名称='" & e.PostValues("大类名称") & "'","小类名称")
e.WriteString("|" & pps)
以上3种写法,不知道有没问题,会不会有什么隐患,因为这个Return,最大的疑问点就是在这个Return上,最原始是直接在HttpRequest事件里,它可以终止了整个HttpRequest事件,HttpRequest恰恰又是个会重复响应请求的事件,对流程的控制要求非常严格,但是我抽取到内部函数以后,它就变了只终止内部函数,但是外面的整个事件还是在继续执行。这样的写法好吗?求老师给一个比较规范的方法,例如那些可以写内部函数里,那些必须外置。
[此贴子已经被作者于2017/5/13 19:20:39编辑过]