ASP中的样式表无法在ASP.net中运行

时间:2012-03-23 16:34:56

标签: asp.net asp-classic vbscript

我在css风格的经典asp中有代码,我想用VB在asp.net中输入相同的代码。当我尝试它时,它只是连续运行循环。谢谢你的帮助。

            <%
            dim img
            img = "baby.jpg"
            %>
            <div class="classname"> <img src="<%response.write baby%>"> </div> 
            <%dim imgPIX
            imgPIX = 60 
            %>
            <style>
            .icons { display: block; width: <%response.write imgPIX%>px; height: <%response.write imgPIX%>px; background-image: url(<%response.write img%>); background-repeat: no-repeat; }
            <%
            dim ico_number,col
            dim row_number,rw

                           //THIS ONE HERE
            for row_number = 1 to 7
             rw = (row_number - 1) * (-1 * imgPIX) 
                for ico_number = 1 to 7
                    col = (ico_number - 1) *(-1 * imgPIX)
                    response.write ".icon"& row_number &"_"& ico_number &" { background-position: "& col &"px "& rw &"px; } "

                    'response.write ".icon"& row_number &"_"& ico_number &" { background-position: 0px 0px; } "
                next
            next 
            %>
            </style>

            <center>
            <table>
            <%for row_number = 1 to 7%>
            <tr>
            <%for ico_number = 1 to 7%>
            <td><span class="icons icon<%response.write row_number%>_<%response.write ico_number%>" style="float:left;"></span></td>
            <%
            next%>
            </tr>
            <%next
            %>
            </table>

2 个答案:

答案 0 :(得分:0)

这看起来不像样式表,而是.aspx或.asp页面。我没有花时间测试这段代码生成的不同样式,但是我运行它并且肯定没有进行无限循环。

答案 1 :(得分:0)

我认为这与样式表没有任何关系,在大多数情况下,样式表只会将外观应用于页面,这不会影响加载时间。如果这是永远运行的for循环:

for row_number = 1 to 7
  rw = (row_number - 1) * (-1 * imgPIX) 
  for ico_number = 1 to 7
     col = (ico_number - 1) *(-1 * imgPIX)
     response.write ".icon"& row_number &"_"& ico_number &" { background-position: "& col &"px "& rw &"px; } "

     'response.write ".icon"& row_number &"_"& ico_number &" { background-position: 0px 0px; } "
   next
next 

就我所知,你的row_number永远不会增加。除非我没有完全遵循代码?