ASP网页开发中遇到的还没有解决的问题

我同学在一个小型的软件开发公司上班,由于大家都是程序员,常常在一起交换心得。
最近,同学给了我一个ASP网页中的问题。我坐了一天 就是没有做出来,不甚感觉自己是菜鸟。
大家都知道,ASP是解释型执行语言,解释型执行语言一个其实是对代码的先后顺序要求一般是比,编译执行的语言要高,同时,在每一次请求时。服务器都会重新解释一次你的代码。速度上来讲,这也是浪费效率的问题,可能这是ASP不如asp.net的一个重要原因吧。我想是。
同学提出的问题是:
ASP中用table嵌套错了一个树目录菜单,然后将这个树目录菜单(动态)嵌入到其他的ASP页面中。用做导航。问题是:
菜单共分三级。当点击一下有连接的子节点时,会提交数据,然后在客户端刷新页面,这样这个原本打开的菜单又回到初始状态了,即关闭状态。(默认是关闭的)
现在是想 当点击连接子节点时,刷新页面会记住菜单的装态。而保持上一次打开的菜单项被打开。就像asp.net中的treeview控件一样。能保存其状态。
我的第一种方案是:
在客户端提交数据时,连同已经打开的子节点的id一起发送到服务器端,服务器端处理完客户端提价的重要数据后,在像客户端返回数据的时候,向客户端浏览器注册一段JavaScript脚本。这段脚本中根据传回的id获取客户端打开的节点,然后将其display属性 设置成block。让其打开。
代码:
<!--#include file="conn.asp"-->
<!--#include file="INC/jbright_char.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="im/jquery.ad-gallery.css">
<script type="text/javascript">
/*
功能描述:js实现,点击一个选项显示其下属项列表,再次点击收起;其他项列表无变化
设计:叶随风(LeafinWind)
QQ:19855466
WEB:http://www.popasp.com/
提示:本例状态用“+”“-”号表示,可以替换成对应的图片只要将对应的符号替换即可
*/
function showList(div_id)
{
var obj = document.getElementById(div_id + "_ljf");
var click_obj = document.getElementById(div_id);
var text = click_obj.innerHTML;
if(obj.style.display == "none")
{
obj.style.display = "block";
click_obj.innerHTML = text.replace("+","-");
}
else
{
obj.style.display = "none";
click_obj.innerHTML = text.replace("-","+");
}
}
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="im/jquery.ad-gallery.js?rand=995"></script>
<script type="text/javascript">
$(function() {
$('img.image1').data('ad-desc', 'Whoa! This description is set through elm.data("ad-desc") instead of using the longdesc attribute.<br>And it contains <strong>H</strong>ow <strong>T</strong>o <strong>M</strong>eet <strong>L</strong>adies... <em>What?</em> That aint what HTML stands for? Man...');
$('img.image1').data('ad-title', 'Title through $.data');
$('img.image4').data('ad-desc', 'This image is wider than the wrapper, so it has been scaled down');
$('img.image5').data('ad-desc', 'This image is higher than the wrapper, so it has been scaled down');
var galleries = $('.ad-gallery').adGallery();
$('#switch-effect').change(
function() {
galleries[0].settings.effect = $(this).val();
return false;
}
);
$('#toggle-slideshow').click(
function() {
galleries[0].slideshow.toggle();
return false;
}
);
});
</script>
<style type="text/css">
* {
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Verdana, Arial, sans-serif;
color: #ffffff;
line-height: 140%;
}
select, input, textarea {
font-size: 1em;
}
body {
font-size: 70%;
width: 800px;
background-color: #000000;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
h2 {
margin-top: 1.2em;
margin-bottom: 0;
padding: 0;
border-bottom: 1px dotted #dedede;
}
h3 {
margin-top: 1.2em;
margin-bottom: 0;
padding: 0;
}
.example {
border: 1px solid #CCC;
background: #f2f2f2;
padding: 10px;
}
ul {
list-style-image:url(list-style.gif);
}
pre {
font-family: "Lucida Console", "Courier New", Verdana;
border: 1px solid #CCC;
background: #f2f2f2;
padding: 10px;
}
code {
font-family: "Lucida Console", "Courier New", Verdana;
margin: 0;
padding: 0;
}

#gallery {
padding: 30px;
background: #000000;
}
</style>
<title>余姚市依格装饰经纪有限公司</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="im/css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE1 {color: #EE4332}
-->
</style>
</head>
<body>
<table width="1003" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="320"><table width="320" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom"><table height="525" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom"><table width="50" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><a href="home.asp"><img src="im/index_r1_c7.jpg" width="148" height="68" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="bottom"><img src="im/index9_r3_c1.jpg" width="222" height="249"></td>
</tr>
</table></td>
<td width="77" height="525"><table width="140" border="0" cellpadding="0" cellspacing="0" bgcolor="#171717">
<tr>
<td height="1" bgcolor="#000000"></td>
</tr>
<tr>
<td height="30"><img src="im/index9_r1_c3.jpg" alt="1" width="77" height="114"></td>
</tr>
<tr>
<td height="25"><table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="10"><div align="left"><img src="im/index6.jpg" alt="1" width="3" height="5"></div></td>
<td class="cn2"><div align="left"><a href="home.asp" class="cn2">公司简介</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="25"><table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="10"><div align="left"><img src="im/index6.jpg" alt="1" width="3" height="5"></div></td>
<td class="cn2"><div align="left"><a href="architecture.asp" class="cn2">企业构架</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="25"><table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="10"><div align="left"><img src="im/index6.jpg" alt="1" width="3" height="5"></div></td>
<td class="cn2"><div align="left"><a href="news.asp" class="cn2">最新动态</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="25"><table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="10"><div align="left"><img src="im/index6.jpg" alt="1" width="3" height="5"></div></td>
<td class="cn2"><div align="left"><a href="team.asp" class="cn2">设计团队</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="25"><table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td class="cn2"><div id="pNode2" οnclick="showList(this.id);" style="cursor:pointer;" align="left" class="cn2"><img src="im/index6.jpg" alt="1" width="3" height="5"> 项目作品</div>
<div id="pNode2_ljf" style="display:none;">
<%
set rs=server.CreateObject("adodb.recordset")
Sql = "select * from Node where 1=1 order by Node_id asc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
else
contn="select count(*) from Node"
for n = 1 to contn
while not rs.eof and n<contn %>
<div id="pNode2_sub<%=n%>" οnclick="showList(this.id);" style="padding-left:10px; cursor:pointer;" class="cn2"><span class="STYLE1">+</span><%=rs("Node_name")%></div>
<div id="pNode2_sub<%=n%>_ljf" style="display:none;">
<%
set rst=server.CreateObject("adodb.recordset")
Sqlt = "select * from Tode where Tode_Nid="&rs("Node_id")&" order by Tode_id desc"
rst.open sqlt,conn,1,1
if rst.eof and rst.bof then
else
cont="select count(*) from Tode"
while not rst.eof and t<cont %>
<div id="pNode2_sub<%=n%>_s<%=t%>" style="padding-left:20px;" class="cn2"> <span class="STYLE1">:</span><a href="products.asp?tid=<%=rst("Tode_id")%>&showid1=<%=n%>&showid2=<%=t %>" class="cn3"><%=rst("Tode_name")%></a></div>
<%rst.movenext
t=t+1
wend
end if
rst.close:set rst=nothing
%>
</div>
<%rs.movenext
n=n+1
wend
if rs.eof then exit for
next
end if
rs.close:set rs=nothing
%>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="25"><table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="10"><div align="left"><img src="im/index6.jpg" alt="1" width="3" height="5"></div></td>
<td class="cn2"><div align="left"><a href="process.asp" class="cn2">服务流程</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="25"><table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="10"><div align="left"><img src="im/index6.jpg" alt="1" width="3" height="5"></div></td>
<td class="cn2"><div align="left"><a href="recruitment.asp" class="cn2">招聘信息</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="25"><table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="10"><div align="left"><img src="im/index6.jpg" alt="1" width="3" height="5"></div></td>
<td class="cn2"><div align="left"><a href="contact.asp" class="cn2">联系我们</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="25"><table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="10"><div align="left"><img src="im/index6.jpg" alt="1" width="3" height="5"></div></td>
<td class="cn2"><div align="left"><a href="guestbook.asp" class="cn2">客户留言</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="20"><img src="im/index9_r4_c3.jpg" alt="1" width="77" height="134"></td>
</tr>
</table></td>
</tr>
</table></td>
<td valign="middle"><table width="464" height="450" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#000000"><div id="gallery" class="ad-gallery">

<div class="ad-image-wrapper"> </div>
<div class="ad-controls"> </div>
<div class="ad-nav">
<div class="ad-thumbs">
<ul class="ad-thumb-list">
<%
[color=red]id1=myRequest("showid1",1)
id2=request.QueryString("showid2")
str ="<script language=javascript > "
str =str & " obj1 =document.getElementById('pNode2_sub" & id1 & "');"
str =str & "ob2=document.getElementById('pNode2_sub" & id1 & "_s" & id2 & "');"
str =str & "obj3=document.getElementById('pNode2_ljf');"
str =str & "obj1.style.display='block';obj2.style.display='block';obj3.style.display='block';"
str =str & "</script>"
response.Write(str)[/color]

//response.write "<script language=JavaScript>" & "alert('\n该类别没有还没发表图片" & id2 & "');" & "</script>"
//response.write "<script language=JavaScript>" & "alert(" & ");" & "</script>"
if id2<>"" then
if id1<> "" then

obj.style.display="block"
set obj1=document.getElementById("pNode2_sub"& id1 & "_s" & id2)
obj1.style.display="block"
end if

end if


set rs=server.CreateObject("adodb.recordset")
Sql = "select * from images where i_tid="&myrequest("tid",1)&" order by i_id desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<script language=JavaScript>" & "alert('\n该类别没有还没发表图片');" & "history.back()" & "</script>"
response.end
else
url=request.ServerVariables("PATH_INFO")&"?"
page=request("page")
if page<>"" and isnumeric(page) then page=int(page) else page=1 end if
rall=rs.recordcount
const size=100
rs.pagesize=size
tpage=rs.pagecount
if page<1 or page>tpage then page=1 end if
rs.absolutepage=page
while not rs.eof and n<size %>
<li>
<a href="admin/upload/UploadFiles/<%=rs("i_ximage")%>" width="400" height="266">
<img src="admin/upload/UploadFiles/<%=rs("i_dimage")%>" width="90" height="60" title="<%=rs("i_name")%>" longdesc=""class="image0"> </a>
</li>
<%rs.movenext
n=n+1
wend
end if
rs.close:set rs=nothing
%>
<@
</ul>
</div>
</div>
</div>
</td>
</tr>
</table></td>
</tr>
</table>
<%
%>
<table width="1003" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="im/index_r6_c1.jpg" width="1003" height="2" /></td>
</tr>
<tr>
<td height="35"><div align="center" class="cn">版权所有 © 2009 余姚市依格装饰工程有限公司</div></td>
</tr>
</table>
</body>
</html>现在,我已成功检测到客户端浏览器已经收到了完整的已注册的脚本,但是,视乎这段脚本在客户端根本没有被执行。纳闷。其实在asp脚本中向客户端注册脚本我重来没有做过,不过道理上应该讲的通,行得通的,可是就是没有被执行。
当然,补充说明一下,本人知道使用frameset是可以的 。但是这样会修改很多的代码。也就大动干戈。
如有人碰到这篇文章能解决的,万谢!!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值