我們平時IEWebContr來做菜單時都是在html中直接輸入,也就是說是靜態的,現在要做成動態的,而且菜單級數不定,怎麼來實現呢?筆者通過研究發現,用IEWebContr來做菜單時,菜單項可以直接輸入,也可以用如下的方法指定從某一個文件中讀取菜單項:
<iewc:TreeView runat="server" ID="Treeview1" NAME="Treeview1">
<iewc:TreeNode id="Treenode1" runat="server" TreeNodeSrc="menuone.txt" Expanded="True" Text="信息類別列表">
</iewc:TreeNode>
</iewc:TreeView>
其中menuone.txt的內容如下:
<TREENODES>
<treenode text='蔬菜' NavigateUrl='xxcb_add.aspx?classname=蔬菜&classid=01'? Target='main1'>
<treenode text='白菜' NavigateUrl='xxcb_add.aspx?classname=白菜&classid=0101'?? Target='main1'/>
<treenode text='蘿卜' NavigateUrl='xxcb_add.aspx?classname=蘿卜&classid=0102'?? Target='main1'/>
<treenode text='黃花菜' NavigateUrl='xxcb_add.aspx?classname=黃花菜&classid=0103'?? Target='main1'/>
</treenode>
<treenode text='水果' NavigateUrl='xxcb_add.aspx?classname=水果&classid=02'? Target='main1'>
<treenode text='蘋果' NavigateUrl='xxcb_add.aspx?classname=蘋果&classid=0201'? Target='main1'>
<treenode text='紅富士' NavigateUrl='xxcb_add.aspx?classname=紅富士&classid=020101'?? Target='main1'/>
<treenode text='其它蘋果' NavigateUrl='xxcb_add.aspx?classname=其它蘋果&classid=020102'?? Target='main1'/>
</treenode>
<treenode text='桃子' NavigateUrl='xxcb_add.aspx?classname=桃子&classid=0202'?? Target='main1'/>
<treenode text='荔枝' NavigateUrl='xxcb_add.aspx?classname=荔枝&classid=0203'?? Target='main1'/>
</treenode>
<treenode text='糧食' NavigateUrl='xxcb_add.aspx?classname=糧食&classid=03'? Target='main1'>
<treenode text='大米' NavigateUrl='xxcb_add.aspx?classname=大米&classid=0301'?? Target='main1'/>
<treenode text='玉米' NavigateUrl='xxcb_add.aspx?classname=玉米&classid=0302'?? Target='main1'/>
</treenode>
</TREENODES>