我做的论坛在addnew.aspx页面中发帖完后重新指向bbs.aspx后为什么要重新刷新一下页面才能显示我发的帖子(代码附下),各位大哥大姐救救我吧:)
<%@import namespace="system.data.oledb"%>
<%@import namespace="system.data"%>
<%@ Page Language="vb" debug="true" %>
<body>
<!--#include virtual="head.inc"-->
<script language=vb runat=server>
sub page_load(sender as object,e as eventargs)
if session("username") = "" then
response.redirect("bbs_login.aspx")
end if
end sub
sub Addnew_Subject_Submit(sender as object,e as eventargs)
'=============上传图片===============================
dim i as integer
dim finfo as string
dim img as string
dim postedfile as httppostedfile=request.files(I)
'================================================
if postedfile.contentlength>0 then
dim filesplit() as string=split(postedfile.filename,"\")
dim filename as string=filesplit(filesplit.length-1)
postedfile.saveas(server.mappath("db\uploadfile")&"\"&filename)
dim imgpath as string ="db\uploadfile\"&filename
img="<img src="+imgpath+" border=0>"
end if
'=======================================提交文本信息==
dim mycommand as OLEDBcommand
dim conn as OLEDBconnection
dim updatestring as string
dim subjectstr as string= subject.text
dim flage as string="subject"
dim description as string=text1.text
dim username as string=session("username")
dim userhead as string=session("userhead")
dim bianmian as string
bianmian = request("banmian")
'================格式转换======================
subjectstr=subjectstr.Replace("&","&")
subjectstr=subjectstr.Replace("<","<")
subjectstr =subjectstr.Replace(">",">")
subjectstr =subjectstr.Replace(chr(32)," ")
subjectstr =subjectstr.Replace("'","’")
subjectstr=subjectstr.Replace(chr(13),"<br>")
subjectstr=subjectstr.Replace(chr(10),"<br>")
'================格式转换======================
dim contentstr as string=content.text
contentstr=contentstr.Replace("&","&")
contentstr=contentstr.Replace("<","<")
contentstr =contentstr.Replace(">",">")
contentstr =contentstr.Replace(chr(32)," ")
contentstr =contentstr.Replace("'","’")
contentstr=contentstr.Replace(chr(13),"<br>")
contentstr=contentstr.Replace(chr(10),"<br>")
'============
description=description.Replace("&","&")
description=description.Replace("<","<")
description =description.Replace(">",">")
description=description.Replace(chr(32)," ")
description=description.Replace("'","’")
description=description.Replace(chr(13),"<br>")
'=====================将转换后的字符串保存到数据库===
if username="" then
username="未知"
end if
updatestring="insert into content (subject,content,subdate,flage,subname,headimg,hitnum,replynum,img,imgdescription,bname)values('"+subjectstr+"','"+contentstr+"',NOW(),'"+flage+"','"+username+"','"+userhead+"',0,0,'"+img+"','"+description+"','"+bianmian+"')"
conn=new OLEDBconnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("db\bbs.mdb"))
mycommand=new OLEDBcommand(updatestring,conn)
conn.open()
mycommand.executenonquery()
dim url as string
url = "bbs.aspx?Artname=" & request("banmian") //为什么这里指向了bbs.aspx但要刷
response.Redirect(url) //新后才能显示刚发的帖子???
end sub
</script>
<form enctype="multipart/form-data" runat="server" ID="Form1" style="font-size:9pt;text-align:center" >
当前版面: <asp:Label id="bianmian" runat="server"/>
文章标题:<asp:textbox ID="SUBJECT" runat="server" TextMode="SingleLine" MaxLength="30" size="30"/><br>
文章内容:<ASP:TEXTBOX ID="content" runat="server" textmode="multiline" rows="10" Columns="60"/>
<br>
上传图片:<input type="file" id="fileup1" runat="server" SIZE=50 maxlength=50><br>
图片说明:<asp:textbox id="text1" runat="server" textmode="singleline" maxlength="30" size="30"/><asp:Panel ID="button_panel" runat="server" HorizontalAlign="center"><br>
<asp:button ID="submit" runat="server" OnClick="Addnew_Subject_Submit" Text="发表这篇文章"/>
</asp:Panel>
<asp:Label ID="statues" Runat="server"></asp:Label>
<asp:RequiredFieldValidator
ID="REVPASSWORD"
ControlToValidate="subject"
Display=None
InitialValue=""
ErrorMessage="文章名必须填写!"
Runat=server>
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator
ID="Requiredfieldvalidator1"
ControlToValidate="content"
Display=None
InitialValue=""
ErrorMessage="文章内容必须填写!"
Runat=server>
</asp:RequiredFieldValidator>
<asp:ValidationSummary
ID="ValidationSummary1"
runat=server
EnableViewState=False
ShowSummary=False
HeaderText="文章提交失败,请注意以下规则:"
ShowMessageBox=True
Font-Name=verdana
Font-Size=9pt> </asp:ValidationSummary>
<table width="7%" border="0" align="center" cellpadding="0" cellspacing="1" class=unnamed3>
<tr>
<td width="93%" class=bar ><a href="javascript:history.back(1)">返回上一页</a></td>
</tr>
</table>
<p> </p>
</form>
<!--#include virtual="foot.inc"-->
</body>
<%@import namespace="system.data.oledb"%>
<%@import namespace="system.data"%>
<%@ Page Language="vb" debug="true" %>
<body>
<!--#include virtual="head.inc"-->
<script language=vb runat=server>
sub page_load(sender as object,e as eventargs)
if session("username") = "" then
response.redirect("bbs_login.aspx")
end if
end sub
sub Addnew_Subject_Submit(sender as object,e as eventargs)
'=============上传图片===============================
dim i as integer
dim finfo as string
dim img as string
dim postedfile as httppostedfile=request.files(I)
'================================================
if postedfile.contentlength>0 then
dim filesplit() as string=split(postedfile.filename,"\")
dim filename as string=filesplit(filesplit.length-1)
postedfile.saveas(server.mappath("db\uploadfile")&"\"&filename)
dim imgpath as string ="db\uploadfile\"&filename
img="<img src="+imgpath+" border=0>"
end if
'=======================================提交文本信息==
dim mycommand as OLEDBcommand
dim conn as OLEDBconnection
dim updatestring as string
dim subjectstr as string= subject.text
dim flage as string="subject"
dim description as string=text1.text
dim username as string=session("username")
dim userhead as string=session("userhead")
dim bianmian as string
bianmian = request("banmian")
'================格式转换======================
subjectstr=subjectstr.Replace("&","&")
subjectstr=subjectstr.Replace("<","<")
subjectstr =subjectstr.Replace(">",">")
subjectstr =subjectstr.Replace(chr(32)," ")
subjectstr =subjectstr.Replace("'","’")
subjectstr=subjectstr.Replace(chr(13),"<br>")
subjectstr=subjectstr.Replace(chr(10),"<br>")
'================格式转换======================
dim contentstr as string=content.text
contentstr=contentstr.Replace("&","&")
contentstr=contentstr.Replace("<","<")
contentstr =contentstr.Replace(">",">")
contentstr =contentstr.Replace(chr(32)," ")
contentstr =contentstr.Replace("'","’")
contentstr=contentstr.Replace(chr(13),"<br>")
contentstr=contentstr.Replace(chr(10),"<br>")
'============
description=description.Replace("&","&")
description=description.Replace("<","<")
description =description.Replace(">",">")
description=description.Replace(chr(32)," ")
description=description.Replace("'","’")
description=description.Replace(chr(13),"<br>")
'=====================将转换后的字符串保存到数据库===
if username="" then
username="未知"
end if
updatestring="insert into content (subject,content,subdate,flage,subname,headimg,hitnum,replynum,img,imgdescription,bname)values('"+subjectstr+"','"+contentstr+"',NOW(),'"+flage+"','"+username+"','"+userhead+"',0,0,'"+img+"','"+description+"','"+bianmian+"')"
conn=new OLEDBconnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("db\bbs.mdb"))
mycommand=new OLEDBcommand(updatestring,conn)
conn.open()
mycommand.executenonquery()
dim url as string
url = "bbs.aspx?Artname=" & request("banmian") //为什么这里指向了bbs.aspx但要刷
response.Redirect(url) //新后才能显示刚发的帖子???
end sub
</script>
<form enctype="multipart/form-data" runat="server" ID="Form1" style="font-size:9pt;text-align:center" >
当前版面: <asp:Label id="bianmian" runat="server"/>
文章标题:<asp:textbox ID="SUBJECT" runat="server" TextMode="SingleLine" MaxLength="30" size="30"/><br>
文章内容:<ASP:TEXTBOX ID="content" runat="server" textmode="multiline" rows="10" Columns="60"/>
<br>
上传图片:<input type="file" id="fileup1" runat="server" SIZE=50 maxlength=50><br>
图片说明:<asp:textbox id="text1" runat="server" textmode="singleline" maxlength="30" size="30"/><asp:Panel ID="button_panel" runat="server" HorizontalAlign="center"><br>
<asp:button ID="submit" runat="server" OnClick="Addnew_Subject_Submit" Text="发表这篇文章"/>
</asp:Panel>
<asp:Label ID="statues" Runat="server"></asp:Label>
<asp:RequiredFieldValidator
ID="REVPASSWORD"
ControlToValidate="subject"
Display=None
InitialValue=""
ErrorMessage="文章名必须填写!"
Runat=server>
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator
ID="Requiredfieldvalidator1"
ControlToValidate="content"
Display=None
InitialValue=""
ErrorMessage="文章内容必须填写!"
Runat=server>
</asp:RequiredFieldValidator>
<asp:ValidationSummary
ID="ValidationSummary1"
runat=server
EnableViewState=False
ShowSummary=False
HeaderText="文章提交失败,请注意以下规则:"
ShowMessageBox=True
Font-Name=verdana
Font-Size=9pt> </asp:ValidationSummary>
<table width="7%" border="0" align="center" cellpadding="0" cellspacing="1" class=unnamed3>
<tr>
<td width="93%" class=bar ><a href="javascript:history.back(1)">返回上一页</a></td>
</tr>
</table>
<p> </p>
</form>
<!--#include virtual="foot.inc"-->
</body>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货