标题:ASP排版请教,怎样使后台自动生成的二级按钮菜单自动换行? 问题可能代码片 ...
只看楼主
zunyiart
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-8-24
结帖率:100%
已结贴  问题点数:20 回复次数:6 
ASP排版请教,怎样使后台自动生成的二级按钮菜单自动换行? 问题可能代码片段粘贴如下:
问题的图文阐述,图片地址:www.

那个按钮背景图是132x25像素,那一排可以用来显示内容的是905像素,网页总宽度是991像素
您能把代码写给我吗?我没有学过asp语言,不太懂

Sub ShowLeftMenu()
 dim rs,ClassId
     ClassId=Request("ClassId")
     if ClassId="" then
        ClassId=8
     End if        
 set rs=Server.CreateObject("adodb.recordset")
      rs.open "select * from tbNewsSort where pid=2 ORder by SerialNum asc",Conn,1,1
     if not rs.eof then
       do while not rs.eof
         if rs("id")=Cint(ClassId) then
         response.Write("<td class=""tab1"" align=""center"">")
         else
         response.Write("<td class=""tab2"" align=""center"">")
         end if
         'response.Write("<div  style=""margin-left:10px;"">")
         response.Write("<a href='Works.asp?ClassId="&rs("id")&"'>")
         'response.Write("·")
         response.Write(rs("SortName"))
         response.Write("</a>")
         response.Write("</td>")
         'response.Write("</div></td></tr>")  & vbcrlf
       rs.movenext
       loop
     end if
End Sub
搜索更多相关主题的帖子: Request where 
2012-08-24 14:50
netlin
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:24
帖 子:544
专家分:4308
注 册:2012-4-9
得分:20 
楼主,对你的代码进行了一些补充,用红色字体标出了,你试试看:

Sub ShowLeftMenu()
dim rs,ClassId
     ClassId=Request("ClassId")
     if ClassId="" then
        ClassId=8
     End if        
set rs=Server.CreateObject("adodb.recordset")
      rs.open "select * from tbNewsSort where pid=2 ORder by SerialNum asc",Conn,1,1
     if not rs.eof then
        i=1
       do while not rs.eof
        if i mod 7=1 then if i=1 then response.write "<tr>" else response.write "</tr><tr>"
         if rs("id")=Cint(ClassId) then
         response.Write("<td class=""tab1"" align=""center"">")
         else
         response.Write("<td class=""tab2"" align=""center"">")
         end if
         'response.Write("<div  style=""margin-left:10px;"">")
         response.Write("<a href='Works.asp?ClassId="&rs("id")&"'>")
         'response.Write("·")
         response.Write(rs("SortName"))
         response.Write("</a>")
         response.Write("</td>")
         'response.Write("</div></td></tr>")  & vbcrlf
        i=i+1
       rs.movenext
       loop
        do while i mod 7<>1
            if rs("id")=Cint(ClassId) then
                 response.Write("<td class=""tab1"" align=""center"">&nbsp;</td>")
            else
                 response.Write("<td class=""tab2"" align=""center"">&nbsp;</td>")
            end if
            i=i+1
        loop
        response.write "</tr>"
     end if
End Sub

做自己喜欢的事!
2012-08-24 22:52
zunyiart
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-8-24
得分:0 
谢谢您的热心帮忙。
我测试了。出现了页面打不开的状况。特将错误信息粘贴如下:
技术信息(用于支持人员)

错误类型:
(0x80020009)
发生意外。
/Works.asp, 第 190 行

浏览器类型:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; QQDownload 717; chromeframe/21.0.1180.60; BTRS126366; .NET CLR 2.0.50727)

网页:
GET /Works.asp

时间:
2012年8月24日, 23:30:36

详细信息:
Microsoft 支持

190行=     if rs("id")=Cint(ClassId) then

您看还能找到解决问题的办法吗
2012-08-24 23:35
netlin
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:24
帖 子:544
专家分:4308
注 册:2012-4-9
得分:0 
楼主,你原来的代码能正常运行吗?
你原来的代码中,表格缺少行开始的标志:<tr>

做自己喜欢的事!
2012-08-24 23:50
zunyiart
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-8-24
得分:0 
您好。原来代码运行是正常的,这个网站的网址是:www.
2012-08-26 19:29
zunyiart
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-8-24
得分:0 
这个页面的完整代码如下:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="conn.asp"-->
<!--#include file="Inc/Config.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%
    ClassId=Request.QueryString("ClassId")
   
   If ClassId="" Then
     ' Rs.OPen "Select * From TbNews WHere Sort in (Select top 1 id from TbNewsSort where Pid=2 ORder by id desc ) ORder by SerialNum desc",conn,1,1
      Rs.Open "Select * From TbNews Where Sort=8 Order by SerialNum desc",Conn,1,1
   Else
      Rs.Open "Select * From TbNews Where Sort="&Cint(ClassId)&" Order by SerialNum desc",Conn,1,1
   End if
   
%>
<link rel="stylesheet" type="text/css" href="Css/Main.css" />
<link rel="stylesheet" type="text/css" href="Css/Style.css" />
<title>作品展示_<%=Sitename%></title>
<script src="Comm.js"></script>
</head>
<body class="Body-Extend">
<!--#include file="head.asp"-->   
<div style="width:100%; background:url(Images/fbg.jpg) repeat #FFF;">
   <table cellpadding="0" cellspacing="0" width="991" align="center" style="width:991px; background:url(Images/centerline.gif) repeat #FFF;">
     <tr>
          <td valign="top" align="right">
             <table cellpadding="0"  cellspacing="0" border="0" style="margin:10px 30px 0 30px;">
               <tr>
                  <%Call ShowLeftMenu()%>
               </tr>
            </table>     
          </td>
     </tr>
     <tr><td height="5"> </td></tr>
     <tr>
         <td style="width:991px; background:url(Images/centerline.gif) repeat;" height="400" valign="top" align="left">
             <table cellpadding="0" cellspacing="0" border="0" width="905" style="margin:25px 0 0 43px;">
              <tr>
                  <td valign="top" align="left">
                     <table cellpadding="0" cellspacing="0" border="0">
                        <tr><td class="title1">作品展示</td></tr>
                        <tr><td class="title2">Photo Show</td></tr>
                     </table>   
                  </td>
                  <td valign="top" align="right">
                     <table cellpadding="0" cellspacing="0" border="0" style="margin:20px 0 5px 0px;">
                        <tr>
                           <td><img src="Images/weizhi.jpg" width="44" height="17" border="0"></td>
                           <td>&nbsp;<a href="Index.asp">首页</a>&nbsp;&gt;&nbsp;作品展示&nbsp;&gt;&nbsp;<%Call  ShowPlace()%></td>
                        </tr>
                     </table>   
                  </td>
              </tr>
              <tr><td colspan="2"><img src="Images/line2.jpg" width="905" height="3" border="0"></td></tr>
            </table>
            
            <table cellpadding="0" cellspacing="0" border="0" width="905" style="margin:10px 0 0 45px;">
              <tr>
                  <td valign="top" align="left">
                     <table cellpadding="0" cellspacing="0" border="0" width="900">
                        <tr><td style="line-height:200%;"><table cellpadding="0"  align="center" cellspacing="0" border="0" width="900">
                                        <tr><td height="10" colspan="3"></td></tr>
                                         <%if Rs.EOf then%>
                                         <tr><td colspan="5">暂无内容...</td></tr>
                                          <%Else%>
                                          <%
                                            rs.pagesize=15
                                            '实现分页
                                            if rs.Eof then
                                            rs_total = 0
                                            else
                                            rs_total = rs.RecordCount
                                            end if
                                            dim pageno
                                            getpageno = (Request("pageno"))
                                            if(getpageno = "")then
                                            pageno = 1
                                            else
                                            pageno = getpageno
                                            End if
                                            if(not rs.Eof)then
                                            rs.AbsolutePage = pageno
                                    
                                          %>
                                          <tr>
                                            <%
                                            repeat_rows = 0
                                             do while (repeat_rows < rs.PageSize and not rs.eof)%>
                                          <%
                                          Dim i
                                          If ((i mod 5)=0) then
                                          %>
                                          </tr><tr>
                                          <%End if%>
                                       
                                            <td class="ppbg" valign="top">
                                               <table cellpadding="0" cellspacing="0" border="0" style="margin-left:10px; margin-top:10px;">
                                                 <tr><td>
                                                     <div style=" border:0px solid #CCC; padding:0px;">
                                                        <a  href="Works_Show.asp?ClassId=<%=Rs("Sort")%>&id=<%=Rs("id")%>"><img src="<%=Rs("CoverPic")%>" width="160" height="160" border="0"></a>
                                                     </div>
                                                 </td></tr>
                                                 <tr><td height="10"></td></tr>
                                                 <tr><td align="center" height="25">
                                                      <%=Rs("title")%></td></tr>
                                              </table>
                                            </td>
                                            
                                          <%
                                          repeat_rows=repeat_rows + 1
                                          i=i+1
                                          Rs.MOvenext
                                          Loop
                                          %>
                                          </tr>
                                          <tr><td colspan="6" align="right"><div align="right" class="style4">
                   [<%=pageno%>/<%=rs.PageCount%>]&nbsp;每页<%=rs.PageSize%>条&nbsp;共<%=rs_total%>条记录
                    <%
                    if(pageno <> 1)then
                    %>
                    <a href="?ParentId=<%=Request("Parentid")%>&ClassId=<%=Request("ClassId")%>">第一页</a>
                    <%
                    End if
                    if(pageno <> 1)then
                    %>
                    <a href="?ParentId=<%=Request("Parentid")%>&ClassId=<%=Request("ClassId")%>&pageno=<%=(pageno-1)%>">上一页</a>
                    <%
                    end if
                    if(instr(pageno,cstr(rs.pagecount)) = 0)then
                    %>
                    <a href="?ParentId=<%=Request("Parentid")%>&ClassId=<%=Request("ClassId")%>&pageno=<%=(pageno+1)%>">下一页</a>
                    <%
                    end if
                    if(instr(pageno,cstr(rs.pagecount)) = 0)then
                    %>
                    <a href="?ParentId=<%=Request("Parentid")%>&ClassId=<%=Request("ClassId")%>&pageno=<%=rs.pagecount%>">最后一页</a>
                    <%
                    end if
                    rs.close
                    Set rs = Nothing
                    end if
                    %>
                </div></td></tr>
                                          <%End if%>
                                   </table>
</td></tr>
                     </table>   
                  </td>
              </tr>
            </table>   
         </td>
     </tr>
   </table>
</div>
<!--#include file="foot.asp"-->   
</body>
</html>
<%
Sub ShowLeftMenu()
 dim rs,ClassId
     ClassId=Request("ClassId")
     if ClassId="" then
        ClassId=8
     End if        
 set rs=Server.CreateObject("adodb.recordset")
      rs.open "select * from tbNewsSort where pid=2 ORder by SerialNum asc",Conn,1,1
     if not rs.eof then
       do while not rs.eof
         if rs("id")=Cint(ClassId) then
         response.Write("<td class=""tab1"" align=""center"">")
         else
         response.Write("<td class=""tab2"" align=""center"">")
         end if
         'response.Write("<div  style=""margin-left:10px;"">")
         response.Write("<a href='Works.asp?ClassId="&rs("id")&"'>")
         'response.Write("·")
         response.Write(rs("SortName"))
         response.Write("</a>")
         response.Write("</td>")
         'response.Write("</div></td></tr>")  & vbcrlf
       rs.movenext
       loop
     end if
End Sub

Sub ShowPlace()
  Dim Rs,ClassId
      ClassId=Request.QueryString("ClassId")
  Set Rs=Server.CreateObject("Adodb.Recordset")
      if ClassId="" then
           Response.Write("所有作品")
      ELse     
          Rs.open "Select * from tbNewsSort WHere id="&Cint(ClassID)&" ",Conn,1,1
          If Not Rs.Eof then
            Response.Write(Rs("SortName"))
          ENd if
     End If         
End Sub
%>
2012-08-26 19:57
zunyiart
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-8-24
得分:0 
回复 4楼 netlin
源码前台整站打包下载地址:www.
希望能够帮助你研究。谢谢。
2012-08-26 20:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-380042-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.742895 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved