|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。asp.net|菜单|静态 我们平常IEWebContr来做菜单时都是在html中间接输出,也就是说是静态的,如今要做成静态的,并且菜单级数不定,怎样来完成呢?笔者经由过程研讨发明,用IEWebContr来做菜单时,菜单项能够间接输出,也能够用以下的办法指定从某一个文件中读取菜单项:
<iewc:TreeViewrunat="server"ID="Treeview1"NAME="Treeview1">
<iewc:TreeNodeid="Treenode1"runat="server"TreeNodeSrc="menuone.txt"Expanded="True"Text="信息种别列表">
</iewc:TreeNode>
</iewc:TreeView>
个中menuone.txt的内容以下:
<TREENODES>
<treenodetext=蔬菜NavigateUrl=xxcb_add.aspx?classname=蔬菜&classid=01?Target=main1>
<treenodetext=白菜NavigateUrl=xxcb_add.aspx?classname=白菜&classid=0101??Target=main1/>
<treenodetext=萝卜NavigateUrl=xxcb_add.aspx?classname=萝卜&classid=0102??Target=main1/>
<treenodetext=黄花菜NavigateUrl=xxcb_add.aspx?classname=黄花菜&classid=0103??Target=main1/>
</treenode>
<treenodetext=生果NavigateUrl=xxcb_add.aspx?classname=生果&classid=02?Target=main1>
<treenodetext=苹果NavigateUrl=xxcb_add.aspx?classname=苹果&classid=0201?Target=main1>
<treenodetext=红富士NavigateUrl=xxcb_add.aspx?classname=红富士&classid=020101??Target=main1/>
<treenodetext=别的苹果NavigateUrl=xxcb_add.aspx?classname=别的苹果&classid=020102??Target=main1/>
</treenode>
<treenodetext=桃子NavigateUrl=xxcb_add.aspx?classname=桃子&classid=0202??Target=main1/>
<treenodetext=荔枝NavigateUrl=xxcb_add.aspx?classname=荔枝&classid=0203??Target=main1/>
</treenode>
<treenodetext=食粮NavigateUrl=xxcb_add.aspx?classname=食粮&classid=03?Target=main1>
<treenodetext=年夜米NavigateUrl=xxcb_add.aspx?classname=年夜米&classid=0301??Target=main1/>
<treenodetext=玉米NavigateUrl=xxcb_add.aspx?classname=玉米&classid=0302??Target=main1/>
</treenode>
</TREENODES>
如今的成绩酿成了怎样将数据表依据“种别号”修正menuone.txt文件。将该历程放在对数据表修正落后行。上面是依据表的内容天生menuone.txt的源代码:
ImportsSystem.IO
DimtxtwriterAsStreamWriter
txtwriter=File.CreateText(Server.MapPathstrpath("menuone.txt"))
txtwriter.WriteLine("<TREENODES>")
DimobjConnAsOleDbConnection
DimobjCmdAsOleDbCommand
DimobjReadAsOleDbDataReader
DimstrSQL,strDSNAsString
Dimstrid,strname,strid1,strname1AsString
DimstrandAsString
strand="&"
Dimi,j,k,mAsInteger
i=0
j=0
k=0
m=0
strSQL="select*fromclassorderbyclassid"
objConn=NewOleDbConnection(ConfigurationSettings.AppSettings("connString"))
objCmd=NewOleDbCommand(strSQL,objConn)
objCmd.Connection.Open()
objRead=objCmd.ExecuteReader()
WhileobjRead.Read()
Ifj=0Then
j=Len(Trim(objRead.Item("classid")))
Else
strid=strid1
strname=strname1
i=Len(Trim(objRead.Item("classid")))
k=i-j
SelectCasek
CaseIs>0
txtwriter.WriteLine("<treenodetext="&strname&"NavigateUrl=xxcb_add.aspx?classname="&strname&""&strand&"classid="&strid&"Target=main1>")
CaseIs=0
txtwriter.WriteLine("<treenodetext="&strname&"NavigateUrl=xxcb_add.aspx?classname="&strname&""&strand&"classid="&strid&"Target=main1/>")
CaseIs<0
txtwriter.WriteLine("<treenodetext="&strname&"NavigateUrl=xxcb_add.aspx?classname="&strname&""&strand&"classid="&strid&"Target=main1/>")
txtwriter.WriteLine("</treenode>")
m=k
Whilem<0
txtwriter.WriteLine("</treenode>")
m=m+2
EndWhile
EndSelect
j=Len(Trim(objRead.Item("classid")))
EndIf
strid1=Trim(objRead.Item("classid"))
strname1=Trim(objRead.Item("classname"))
EndWhile
strid=strid1
strname=strname1
i=Len(strid)
k=j-i
strid=strid1
strname=strname1
SelectCasek
CaseIs>0
txtwriter.WriteLine("<treenodetext="&strname&"NavigateUrl=xxcb_add.aspx?classname="&strname&""&strand&"classid="&strid&"Target=main1/>")
txtwriter.WriteLine("</treenode>")
m=Len(strid)/2
Whilem>1
txtwriter.WriteLine("</treenode>")
m=m-1
EndWhile
CaseIs=0
txtwriter.WriteLine("<treenodetext="&strname&"NavigateUrl=xxcb_add.aspx?classname="&strname&""&strand&"classid="&strid&"Target=main1/>")
txtwriter.WriteLine("</treenode>")
m=Len(strid)/2
Whilem>1
txtwriter.WriteLine("</treenode>")
m=m-1
EndWhile
CaseIs<=0
txtwriter.WriteLine("<treenodetext="&strname&"NavigateUrl=xxcb_add.aspx?classname="&strname&""&strand&"classid="&strid&"Target=main1/>")
txtwriter.WriteLine("</treenode>")
m=Len(strid)/2
Whilem>1
txtwriter.WriteLine("</treenode>")
m=m-1
EndWhile
EndSelect
txtwriter.WriteLine("</TREENODES>")
txtwriter.Close()
如许menuone.txt就按请求天生了菜单源文件。Windows本身的所有问题都会一成不变的也累加到了它的身上。安全性、稳定性、跨平台性都会因为与NT的捆绑而显现出来; |
|