简体   繁体   English

如何在asp.net中编写这个经典的asp

[英]How to go about writing this classic asp in asp.net

I am stuck in converting this snipped to asp.net. 我被困在将这个剪切转换为asp.net。

set RSLinksCat = conn.Execute("select linkscat.id, linkscat.category from linkscat, contentlinks, links where contentlinks.linksid = links.id and contentlinks.contentid = " & contentid & " and links.linkscatid = linkscat.id order by linkscat.category")


<%if not RSLinksCat.EOF then%><h1>Links</h1>
<br />
<%do while not RSLinksCat.EOF%>
<%set RSLinks = conn.Execute("select * from links where linkscatid = " & RSLinksCat("id") & "")%>

 <strong><%=RSlinkscat("category")%><strong>
    <ul>
                    <%do while not RSlinks.EOF%>
                    <li>
                      <a href = "http://<%=RSLinks("url")%>" target="_blank"><%=RSlinks("description")%></a>
                    </li>
                     <%RSLinks.MoveNext
                    loop%>
    </ul>
                 <%RSLinksCat.MoveNext
                 loop%>
<br />
<%end if%><%conn.close%>

I'm not sure where to start. 我不知道从哪里开始。 Can anyone recommend the correct approach ie sqldatareaders or repeaters or arrays or sqldatareaders or? 任何人都可以推荐正确的方法,即sqldatareaders或中继器或阵列或sqldatareaders或? VB code samples most welcome. VB代码样本最受欢迎。

Thanks 谢谢

If you came from the ASP Classic world, you may find ASP.net MVC easy to deal with. 如果您来自ASP Classic世界,您可能会发现ASP.net MVC易于处理。 No need to learn what server control do you need or how to deal with the ViewState. 无需了解您需要哪种服务器控件或如何处理ViewState。

Converted code, using LINQ as DAL: 转换代码,使用LINQ作为DAL:

<h1>Links</h1>
<br />
<% For each linkcat in Model%>
<strong><%=linkcat.category%><strong>
  <ul>
     <% For each link in linkcat.Links%>
        <li>
        <a href="http://<%=Link.url%>" target="_blank"><%=links.description%></a>
        </li>
    <% Next %>
    </ul>
<br />
<% Next %>

请查看DataList,Repeater或类似的Server Control示例,了解如何实现所需的内容。

Phil 菲尔

Start from give some small time and find a Dal Data access layer , a communication way with your database, like subsonic 2.3, or linq to sql. 从给出一些小的时间开始,找到一个Dal数据访问层 ,与数据库的通信方式,如亚音速2.3,或linq到sql。

Then if you see any example on this DALs and play few days with it, the rest will be very easy. 然后,如果您在此DAL上看到任何示例并使用它玩几天 ,其余的将非常简单。

Also you need to move from asp to asp.net thinking that asp.net is something different, and not because both have the asp, means something. 另外你需要从asp转到asp.net,认为asp.net是不同的东西,而不是因为两者都有asp,意味着什么。 I mean that you do not just port the code from one to the other... needs more to get out the thesaurus of asp.net. 我的意思是你不只是将代码从一个移植到另一个......需要更多的东西来获取asp.net的词库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM