How to go about converting this classic asp to asp.net
- by Phil
I have some classic asp code that needs converting to asp.net. So far I have tried to achieve this using datareaders and repeaters and had no luck as the menu loops through 4 different record sets, passing along the menuNid before moving to the next record.
Please can you tell me what method you would use to conver this code... i.e datareaders? dataset? etc?
Thanks
<%
set RSMenuLevel0 = conn.execute("select id, DepartmentID, GroupingID, Heading, OrderID, Publish, moduleid, url, urltarget " &_
"from T where (DepartmentID = 0 and GroupingID = 0 and Publish <> 0) order by OrderID")
%>
<%
if session("JavaScriptEnabled") = "False" Then
%>
<%
while not RSMenuLevel0.EOF
if RSMenuLevel0("Publish") <> 0 then
Menu0heading = RSMenuLevel0("Heading")
Menu0id = RSMenuLevel0("id")
%>
<%if RSMenuLevel0("url") > "" and RSMenuLevel0("moduleid") = 0 then%>
<a href="http://<%=RSMenuLevel0("url")%>" target="<%=RSMenuLevel0("urltarget")%>"><%=Menu0heading%></a>
<%else%>
<a href="/default.asp?id=<%=Menu0id%>"><%=Menu0heading%></a>
<%end if%>
<%
end if
RSMenuLevel0.MoveNext
wend
%>
<%
else
%>
<ul id="Menu1" class="MM">
<%if home <> 1 then%>
<!-- <li><a href="/default.asp"><span class="item">Home</span></a> -->
<%end if%>
<%
numone=0
while not RSMenuLevel0.EOF
' numone = numone + 1
Menu0heading = RSMenuLevel0("Heading")
'itemID = lcase(replace(Menu0heading," ",""))
Menu0id = RSMenuLevel0("id")
if RSMenuLevel0("url") > "" and RSMenuLevel0("moduleid") = 0 then
url = RSMenuLevel0("url")
if instr(url,"file:///") > 0 then
%>
<li><a href="<%=RSMenuLevel0("url")%>" target="<%=RSMenuLevel0("urltarget")%>" <%if numone=1 then%>class="CURRENT"<%end if%>><span class="item"><%=Menu0heading%></span></a>
<%else%>
<li><a href="http://<%=RSMenuLevel0("url")%>" target="<%=RSMenuLevel0("urltarget")%>" <%if numone=1 then%>class="CURRENT"<%end if%>><span class="item"><%=Menu0heading%></span></a>
<%end if%>
<%else%>
<li><a href="/default.asp?id=<%=RSMenuLevel0("id")%>" <%if numone=1 then%>class="CURRENT"<%end if%>><span class="item"><%=Menu0heading%></span></a>
<%end if%>
<%
set RSMenuLevel1 = conn.execute("select id, DepartmentID, GroupingID, Heading, OrderID, Publish, moduleid, url, urltarget " &_
"from T where (DepartmentID = 0 and GroupingID = " & Menu0id & " and Publish <> 0) order by OrderID")
if not RSMenuLevel1.EOF then
%>
<ul>
<%
while not RSMenuLevel1.EOF
Menu1heading = RSMenuLevel1("Heading")
Menu1id = RSMenuLevel1("id")
if RSMenuLevel1("url") > "" and RSMenuLevel1("moduleid") = 0 then
url = RSMenuLevel1("url")
if instr(url,"file:///") > 0 then
%>
<li><a href="<%=RSMenuLevel1("url")%>" target="<%=RSMenuLevel1("urltarget")%>"><%=Menu1heading%></a>
<%else%>
<li><a href="http://<%=RSMenuLevel1("url")%>" target="<%=RSMenuLevel1("urltarget")%>"><%=Menu1heading%></a>
<%end if%>
<%else%>
<li><a href="/default.asp?id=<%=RSMenuLevel1("id")%>"><%=Menu1heading%></a>
<%end if%>
<%
set RSMenuLevel2 = conn.execute("select id, DepartmentID, GroupingID, Heading, OrderID, Publish, moduleid, url, urltarget " &_
"from T where (DepartmentID = 0 and GroupingID = " & Menu1id & " and Publish <> 0) order by OrderID")
if not RSMenuLevel2.EOF then
%>
<ul>
<%
while not RSMenuLevel2.EOF
Menu2heading = RSMenuLevel2("Heading")
Menu2id = RSMenuLevel2("id")
if RSMenuLevel2("url") > "" and RSMenuLevel2("moduleid") = 0 then
%>
<li><a href="http://<%=RSMenuLevel2("url")%>" target="<%=RSMenuLevel2("urltarget")%>"><%=Menu2heading%></a>
<%else%>
<li><a href="/default.asp?id=<%=RSMenuLevel2("id")%>"><%=Menu2heading%></a>
<%end if%>
<%
set RSMenuLevel3 = conn.execute("select id, DepartmentID, GroupingID, Heading, OrderID, Publish, moduleid, url, urltarget " &_
"from T where (DepartmentID = 0 and GroupingID = " & Menu2id & " and Publish <> 0) order by OrderID")
if not RSMenuLevel3.EOF then
%>
<ul>
<%
while not RSMenuLevel3.EOF
Menu3heading = RSMenuLevel3("Heading")
Menu3id = RSMenuLevel3("id")
if RSMenuLevel3("url") > "" and RSMenuLevel3("moduleid") = 0 then
%>
<li><a href="http://<%=RSMenuLevel3("url")%>" target="<%=RSMenuLevel3("urltarget")%>"><%=Menu3heading%></a></li>
<%else%>
<li><a href="/default.asp?id=<%=RSMenuLevel3("id")%>"><%=Menu3heading%></a></li>
<%end if%>
<%
RSMenuLevel3.MoveNext
wend
%>
</ul>
<%
end if
RSMenuLevel2.MoveNext
%>
</li>
<%
wend
%>
</ul>
<%
end if
RSMenuLevel1.MoveNext
%>
</li>
<%
wend
%>
</ul>
<% end if
RSMenuLevel0.MoveNext
%>
</li>
<%
wend
%>
</ul>
<%
end if
%>