从数据库里面输出的内容刷新后就消失了

significantpeople 2008-12-07 12:18:59
我做了一个新闻页面,是用框架结构的。top.asp是一个导航栏,传递一个类型变量给left.asp。
left.asp是一个显示各类新闻标题页面,传递id给main.asp,
点击相应的标题后新闻内容在main.asp里面显示.其中left.asp和main.asp是从数据库里面读的
但问题是刷新后left.asp和main.asp都没了,只剩下一个导航栏。是怎么回事啊?郁闷
要怎么解决啊?
...全文
356 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
scscms太阳光 2008-12-08
  • 打赏
  • 举报
回复
你传过来的值应该用session("")或者cookies()保存起来,当有新值传过来时就更新session("")或者cookies(),这样怎么刷新都不怕了
significantpeople 2008-12-08
  • 打赏
  • 举报
回复
那我可以使用什么办法把第一次传过来的参数保留起来,这样起到防止刷新的作用啊。
significantpeople 2008-12-08
  • 打赏
  • 举报
回复

commandtext="select * from news where id='"&Request.QueryString("id")&"'"
那我想保存这里面的id,是不是就在这一句后面加上session("id")
但是还是不行啊
-晴天 2008-12-07
  • 打赏
  • 举报
回复
应该是代码中有什么问题吧.
zjzb0409 2008-12-07
  • 打赏
  • 举报
回复
实际上你的做法 还是不合理的 你刷新left.asp 和mian.asp 页面想正常显示 都是需要从上个页链接过来以获取传过来的值
但是你刷新这个页面 值是接收不到的 所以 你应该是 使用5楼提供的框架代码

<frame name="left" target="main" src="top.asp">
<frame name="main" src="admin.asp">
框架左边使用top.asp 右边放一个admin.asp 里边什么内容没有也行

这样你刷新时 刷新的是top.asp 对你没什么影响 然后点击链接 打开left.asp而且值也传过去了 这样新闻标题能看到
在点新闻标题 详细内容也能打开了 就是说 标题页和详细页 都是在右边打开的。。。

top.asp 你得做成 纵向 就跟后台差不多。。个人一点建议
significantpeople 2008-12-07
  • 打赏
  • 举报
回复
这位帅哥,非常感谢你的认真解答。不过安照你的方法改了top的代码,不但没有解决问题还不能显示left和main页面
你所说的浏览器不支持框架结构,貌似不是这个原因。静态的网页我做成框架结构是没有问题的
不知道还有什么原因啊?数据库是不是有什么问题?
-晴天 2008-12-07
  • 打赏
  • 举报
回复
top 有点问题,应为:
<html>
<head>
<base target="contents">
</head>

<body>
<div align="center"> <img src="src/top.gif" width="1000" height="110" alt="精品课程" /> </div>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" valign="middle">
<div align="center"> <a href="index.asp" class="Bar" target="main"> 
<span class="STYLE4">首 页 </span> </a> <span class="WHITE STYLE4">| </span>
<span class="STYLE4"> <a target="left" href="left.asp?classid=news">站内新闻 </a>| </span>
<span class="STYLE4"> <a href="left.asp?classid=information" target="left">123 </a>| </span>
</div>
</td>
</tr>
</table>
</body>
</html>
-晴天 2008-12-07
  • 打赏
  • 举报
回复
top.asp
<html>
<head>
<base target="contents">
</head>

<body>
<div align="center"> <img src="src/top.gif" width="1000" height="110" alt="精品课程" /> </div>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" valign="middle">
<div align="center"> <a href="index.asp" class="Bar"> 
<span class="STYLE4">首 页 </span> </a> <span class="WHITE STYLE4">| </span>
<span class="STYLE4"> <a target="contents" href="left.asp?classid=news">站内新闻 </a>| </span>
<span class="STYLE4"> <a href="left.asp?classid=information" target="_left">123 </a>| </span>
</div>
</td>
</tr>
</table>
</body>
</html>
-晴天 2008-12-07
  • 打赏
  • 举报
回复
框架网页:
<html>

<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<title>新建网页 1</title>
</head>

<frameset rows="180,*">
<frame name="banner" scrolling="no" noresize target="contents" src="top.asp">
<frameset cols="150,*">
<frame name="left" target="main" src="left.asp">
<frame name="main" src="main.asp">
</frameset>
<noframes>
<body>

<p>此网页使用了框架,但您的浏览器不支持框架。</p>

</body>
</noframes>
</frameset>

</html>

left.asp
<html>
<head>
<base target="main">
</head>

<body >

<%
set conn=server.createobject("adodb.connection")
conn.connectionstring = "driver={sql server};server=YourSQLSERVER;uid=sa;pwd=1234;database=test"
conn.open

commandtext="select * from news where classid='"&Request.QueryString("classid")&"'"
set rs = conn.execute(commandtext,recordsaffected,adcmdtext)
If Err.number <>0 Then
Err.clear
Set conn=Nothing
response.write"数据库连接出错!"
response.End

end if
%>

<table width="80%" border="0">
<% do while not rs.eof %>
<tr>
<td height="30"> <a href="main.asp?id= <%=RS("id")%>" target="main" > <%=RS("title")%> </a>

</td>
</tr>


<%
rs.movenext
loop
rs.close
set rs=nothing
%>
</table>
</body>
</html>

main.asp
<body> 

<%
set conn=server.createobject("adodb.connection")
conn.connectionstring = "driver={sql server};server=YourSQLSERVER;uid=sa;pwd=1234;database=test"
conn.open

commandtext="select * from news where id='"&Request.QueryString("id")&"'"
set rs = conn.execute(commandtext,recordsaffected,adcmdtext)
If Err.number <>0 Then
Err.clear
Set conn=Nothing
response.write"数据库连接出错!"
response.End
end if

if not rs.eof then
%>

<table width="80%" height="30" border="0">
<tr>
<td bgcolor="#ECFFFF">
<% response.Write"您当前的位置 »»"%>  <% =RS("classid") %>
<% response.Write" »»"%>  <% =RS("title") %>
<% response.Write(" <br>") %>
</td>
</tr>
<% end if %>
<% do while not rs.eof %>
<tr>
<td height="30" > <%=RS("content")%> </td>
<tr>
<td align="right" > <%=RS("zuozhe")%> <%=RS("riqi")%> </td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
</table>
</body>
Java_And_NET 2008-12-07
  • 打赏
  • 举报
回复


那是你刷新后,自动又获取了一次传过来的值,获取不到,才出现的那种情况,你看一下是否获取到了...
significantpeople 2008-12-07
  • 打赏
  • 举报
回复
给一点提示啊,我也知道是代码问题么.
top.asp

<body>
<div align="center"><img src="src/top.gif" width="1000" height="110" alt="精品课程" />
</div>

<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" valign="middle">
<div align="center"><a href="index.jsp" class="Bar"> 
<span class="STYLE4">首 页</span></a><span class="WHITE STYLE4">|</span>
<span class="STYLE4"><a href="jpkcleft.asp?classid=news" target="left">站内新闻</a>|</span>
<span class="STYLE4"><a href="jpkcleft.asp?classid=information" target="left">123</a>|</span>
</div>
</td>
</tr>
</table>



</body>
</html>

</body>
left.asp代码
<body >

<%

commandtext="select * from news where classid='"&Request.QueryString("classid")&"'"
set rs = conn.execute(commandtext,recordsaffected,adcmdtext)
If Err.number<>0 Then
Err.clear
Set conn=Nothing
response.write"数据库连接出错!"
response.End

end if
%>

<table width="80%" border="0">
<% do while not rs.eof %>
<tr>
<td height="30"><a href="jpkcmain.asp?id= <%=RS("id")%>" target="main" ><%=RS("title")%> </a>

</td>
</tr>


<%
rs.movenext
loop
rs.close
set rs=nothing
%>
</table>
</body>
main.asp代码:
<body>

<%
commandtext="select * from news where id='"&Request.QueryString("id")&"'"
set rs = conn.execute(commandtext,recordsaffected,adcmdtext)
If Err.number<>0 Then
Err.clear
Set conn=Nothing
response.write"数据库连接出错!"
response.End
end if

if not rs.eof then
%>

<table width="80%" height="30" border="0">
<tr>
<td bgcolor="#ECFFFF">
<% response.Write"您当前的位置 »»"%> <% =RS("classid") %>
<% response.Write" »»"%> <% =RS("title") %>
<% response.Write("<br>") %>
</td>
</tr>
<% end if %>
<% do while not rs.eof %>
<tr>
<td height="30" ><%=RS("content")%> </td>
<tr>
<td align="right" ><%=RS("zuozhe")%><%=RS("riqi")%></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
</table>
</body>
帮我看看啊.
layers2323 2008-12-07
  • 打赏
  • 举报
回复
肯定是代码问题。改代码。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧