请教!!
当我加上添加留言的各项后,我再点击留言的"发表留言"按钮,可我在留言的列表上不能马上看到刚加入的留言,只能再次打开留言后才看得到,我如想添加留言的各项后,点击留言的"发表留言"按钮就可在留言的列表上马上看到刚加入的留言,我该怎样改"发表留言"按钮代码啊???"发表留言"按钮的代码如下
<asp:button id="submit" onclick="Addnew_Subject_Submit" runat="server" Text="发表留言"></asp:button>
关键代码如下(bbs.aspx是显示留言列表文件)<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")
'================格式转换======================
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)values('"+subjectstr+"','"+contentstr+"',NOW(),'"+flage+"','"+username+"','"+userhead+"',0,0,'"+img+"','"+description+"')"
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()
response.redirect("bbs.aspx")
end sub
sub reset_form(sender as object,e as eventargs)
subject.text=""
content.text=""
end sub
</script>
当我加上添加留言的各项后,我再点击留言的"发表留言"按钮,可我在留言的列表上不能马上看到刚加入的留言,只能再次打开留言后才看得到,我如想添加留言的各项后,点击留言的"发表留言"按钮就可在留言的列表上马上看到刚加入的留言,我该怎样改"发表留言"按钮代码啊???"发表留言"按钮的代码如下
<asp:button id="submit" onclick="Addnew_Subject_Submit" runat="server" Text="发表留言"></asp:button>
关键代码如下(bbs.aspx是显示留言列表文件)<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")
'================格式转换======================
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)values('"+subjectstr+"','"+contentstr+"',NOW(),'"+flage+"','"+username+"','"+userhead+"',0,0,'"+img+"','"+description+"')"
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()
response.redirect("bbs.aspx")
end sub
sub reset_form(sender as object,e as eventargs)
subject.text=""
content.text=""
end sub
</script>
Response.Write("<script language=javascript>window.location.href=window.location.href;</script>");
源错误:行 74:
行 75:
行 76: Response.Write("<script language=javascript>window.location.href=window.location.href;</script>");
行 77:
行 78:
我把你给的这代码放在<asp:button id="submit" onclick="Addnew_Subject_Submit" runat="server" Text="发表这篇文章"></asp:button>后面,button没功能了和所有的添加留言的文本框不能写入文字了,我该怎么做啊??请大侠回一下啊.
源错误:行 74:
行 75:
行 76: Response.Write("<script language=javascript>window.location.href=window.location.href;</script>");
行 77:
行 78:
我把你给的这代码放在<asp:button id="submit" onclick="Addnew_Subject_Submit" runat="server" Text="发表这篇文章"></asp:button>后面,button没功能了和所有的添加留言的文本框不能写入文字了,我该怎么做啊??请大侠回一下啊.