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

时间:2021-12-17 03:35:28

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 i.e sqldatareaders or repeaters or arrays or sqldatareaders or? VB code samples most welcome.

我不知道从哪里开始。任何人都可以推荐正确的方法,即sqldatareaders或中继器或阵列或sqldatareaders或? VB代码样本最受欢迎。

Thanks

谢谢

3 个解决方案

#1


1  

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. 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转到asp.net,认为asp.net是不同的东西,而不是因为两者都有asp,意味着什么。我的意思是你不只是将代码从一个移植到另一个......需要更多的东西来获取asp.net的词库。

#2


2  

If you came from the ASP Classic world, you may find ASP.net MVC easy to deal with. No need to learn what server control do you need or how to deal with the ViewState.

如果您来自ASP Classic世界,您可能会发现ASP.net MVC易于处理。无需了解您需要哪种服务器控件或如何处理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 %>

#3


1  

Please look at the DataList, Repeater, or similar Server Control samples to see how to implement what you need.

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

#1


1  

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. 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转到asp.net,认为asp.net是不同的东西,而不是因为两者都有asp,意味着什么。我的意思是你不只是将代码从一个移植到另一个......需要更多的东西来获取asp.net的词库。

#2


2  

If you came from the ASP Classic world, you may find ASP.net MVC easy to deal with. No need to learn what server control do you need or how to deal with the ViewState.

如果您来自ASP Classic世界,您可能会发现ASP.net MVC易于处理。无需了解您需要哪种服务器控件或如何处理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 %>

#3


1  

Please look at the DataList, Repeater, or similar Server Control samples to see how to implement what you need.

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