⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 news.asp

📁 机械工业出版社马涛主编的《网站建设与管理》电子课件+示例源码
💻 ASP
字号:
<!--#include file="gg/conn.asp"-->
<%
dim newtext,oldtext

IF Request("del")<>""  Then
   Sql = "Delete From news Where id="&Request("del")
   Conn.Execute(Sql)
   Response.Redirect "gonggao.asp"
End IF

if Request("action")="edit" then
Set rs=Server.CreateObject("ADODB.RecordSet") 
sql="select * from news where id="&request("id")
rs.open sql,conn,1,3 
oldtext=request.form("text")
newtext=replace(oldtext,vbcrlf,"<br>")
if trim(request.form("title"))="" then
  response.write "<script language=javascript>"	
		response.write "alert('请填写标题');"	
		response.write "</script>"
		response.write "<script language=javascript>location='javascript:history.back(1)'</script>"
   Response.End
   end if
   if trim(request.form("text"))="" then
  response.write "<script language=javascript>"	
		response.write "alert('请填写内容');"	
		response.write "</script>"
		response.write "<script language=javascript>location='javascript:history.back(1)'</script>"
   Response.End
   end if
rs("title")=trim(request("title"))
rs("text")=newtext
rs.Update
rs.Close
set rs=nothing
Response.Redirect "gonggao.asp"
end if
if Request("action")="add" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from news"
rs.open sql,conn,3,2
rs.addnew
   if trim(request.form("title"))="" then
  response.write "<script language=javascript>"	
		response.write "alert('请填写标题');"	
		response.write "</script>"
		response.write "<script language=javascript>location='javascript:history.back(1)'</script>"
   Response.End
   end if
   if trim(request.form("text"))="" then
  response.write "<script language=javascript>"	
		response.write "alert('请填写内容');"	
		response.write "</script>"
		response.write "<script language=javascript>location='javascript:history.back(1)'</script>"
   Response.End
   end if
oldtext=trim(request.form("text"))
newtext=replace(oldtext,vbcrlf,"<br>")
rs("title")=trim(request("title"))
rs("text")=newtext
rs.update
rs.close
response.redirect "gonggao.asp"
end if
%>
<html>
<head>
<title>更新公告</title>
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
<!--
.style1 {color: #000000}
input {
	background-color: #FFFFFF;
	border: 1px solid #CCCCCC;
}
-->
</style>
</head>

<body>
<%

sql="select * from news order by id desc" 
Set rs=Server.CreateObject("ADODB.RecordSet") 
rs.Open sql,conn,1,3
'公共翻页模块开始%>
<table width="600" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="#006699">
  <tr> 
    <td align="center" height="23"><b><font color="#FFFFFF">编辑公告</font></b></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">
      <!--#include file=fpage/fpage.asp-->
      <% 
Dim RowCount 
RowCount = 10 '每页显示的记录条数 
Call TurnPage(Rs,RowCount) 
'公共翻页模块结束%>
    </td>
  </tr>
</table>
    
<table width="600" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#00659C" height="17">
  <tr align="center"> 
    <td width="179"><font color="#FFFFFF">标题</font></td>
    <td width="310"><font color="#FFFFFF">内容</font></td>
    <td width="95"><font color="#FFFFFF">操作</font></td>
  </tr>
</table>

<table width="600"  border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
 <% 
If Not Rs.eof then
Do while Not Rs.eof and RowCount>0 
%> 
 <tr> 
    <form action="gonggao.asp?action=edit" method="post">
      <td width="177" bgcolor="#FFFFFF" align="center" > 
        <div align="center"> 
          <input name="title" type="text" value="<%=rs("title")%>" size="26" class="text复制" maxlength="50">
          <input name="id" type="hidden" id="id" value="<%=rs("id")%>">
        </div>
      </td>
      <td width="314" bgcolor="#FFFFFF"> 
        <div align="center"> 
          <textarea name="text" cols="40" rows="4" class="text复制"><%=rs("text")%></textarea>
        </div></td>
      <td width="46" nowrap bgcolor="#FFFFFF"> 
        <div align="center"> 
          <input name="Submit2" type="submit" class="text复制" value="EDIT">
        </div></td>
      <td width="42" nowrap bgcolor="#FFFFFF"> 
        <div align="center"><a href="gonggao.asp?del=<%=Rs("id")%>">删除</a></div></td>
    </form>
  </tr><% 
RowCount = RowCount - 1 
Rs.MoveNext 
Loop 
End If 
%>
</table>
<table width="60%" border="0" cellspacing="0" cellpadding="0" align="center" height="8">
  <tr> 
    <td></td>
  </tr>
</table>

<table width="60%" border="0" cellspacing="0" cellpadding="0" align="center" height="8">
  <tr> 
    <td></td>
  </tr>
</table>

<table width="600" border="0" cellspacing="1" cellpadding="6" align="center" bgcolor="#00659C">
  <tr>
    <td align="center"><b><font color="#FFFFFF">增加公告</font></b></td>
  </tr>
</table>
<table width="600"  border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC">
  <form action="gonggao.asp?action=add" method="post" name="form" >
    <tr> 
      <td bgcolor="#FFFFFF" width="132"> 
        <p align="right" class="style1">标题: 
      </td>
      <td bgcolor="#FFFFFF" width="607"> 
        <input name="title" type="text" class="text复制" size="30">
      </td>
    </tr>
    <tr> 
      <td bgcolor="#FFFFFF" width="132" height="58"> 
        <div align="right" class="style1"> 内容:</div>
      </td>
      <td bgcolor="#FFFFFF" width="607" valign="middle" height="58"> &nbsp;&nbsp;&nbsp; 
        &nbsp;&nbsp;&nbsp;&nbsp; 
        <table width="98%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="70%" height="59"> 
              <textarea name="text" class="text复制" id="password" cols="50" rows="4"></textarea>
            </td>
            <td width="30%" height="59">&nbsp;</td>
          </tr>
        </table>
        
      </td>
    </tr>
    <tr> 
      <td bgcolor="#FFFFFF" width="132"> 
        <div align="right"></div></td>
      <td bgcolor="#FFFFFF" width="607"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input name="Submit" type="submit" class="text复制" value=" 增 加 "> 
        &nbsp;&nbsp;&nbsp; 
        <input name="Submit1" type="reset" class="text复制" value=" 重 设 ">
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
  </form>
</table>
</body>
</html>
<%
  rs.close   
set rs=nothing   
conn.close   
set conn=nothing
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -