crystal nano
01-10-2010, 10:04 AM
i have code for update news. i have two pages one is in which i edit the news. and afrer submit it will go to update_record.asp page in which it is written that news is updated. i want after pressing submit success message show on top of eeit news page. the code for edit news is as follows
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head><title>News Management System - Update News</title>
</head>
<body>
<%
'declare you variables
Dim SQL, connection, recordset,msg
Dim sConnString, ID 'receive the id of the record passed through querystring
ID=request.querystring("ID")
'Declare the SQL statement that will query the database
SQL="SELECT * FROM latestNews WHERE ID=" & ID
'Create an ADO connection and recordset object
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("news_data.mdb")
'Open the connection to our database
Connection.Open(sConnString)
'Open the recordset object, execute the SQL statement
'and return the record with the id that was sent
recordset.Open SQL,connection
%>
<div align='center'>
<table width="370" border="0" cellspacing="0" cellpadding="0" align="center">
<tr align="left" valign="top">
<td>
<div align="center">
<p> </p>
<!-- start the html form -->
<form action="update_record.asp" method="post" name="form" id="frm" runat="server">
<table border="2" bordercolor="#CCCCFF" cellspacing="0" cellpadding="4">
<tr>
<td>
News Title</td>
<td>
<input id="txtAlpha" type="text" name="newstitle" value="<%= recordset("newstitle")%>" size="50"
class="cssborder" onkeyup="keyUP(event.keyCode)" onkeydown="return isAlpha(event.keyCode);"
onpaste="return false;" />
</td>
<td>
<span id="lblAlpha" style="color: Red; font-size: 10pt; font-family: Arial; visibility: hidden;">
* Only Alphabets</span>
</td>
</tr>
<tr>
<td valign="top">
News Text</td>
<td>
<textarea cols="50" rows="8" name="newsbody" class="cssborder"><% response.write recordset("newsbody") %></textarea></td>
</tr>
<tr>
<td>
News Date</td>
<td>
<input type="text" name="newsdate" value="<% response.write recordset("newsdate") %>" size="12" class="cssborder"></td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" name="id" value="<%=id%>">
<input type="hidden" name="ispostback" value="1">
<input type="submit" value="update" class="cssborder" />
<input type="reset" class="cssborder">
</td>
</tr>
</table>
</form>
</div>
<%
'close the connection and recordset objects
recordset.Close
Set recordset=Nothing
connection.Close
Set connection=Nothing
%>
</body>
</html>
the after submit edit news it will go to update_record.asp page the code is:
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head><title>News Management System - Updated News</title>
</head>
<body>
<%
'declare your variables
Dim SQL, connection, recordset, ID
Dim sConnString, newstitle, newsbody, newsdate
newstitle = request.form("newstitle")
newsbody = request.form("newsbody")
newsdate = request.form("newsdate")
ID=request.form("ID") 'receive the hidden form ID
'build the SQL - MAKE SURE YOUR CODE IS ON SAME LINE
SQL = "UPDATE latestNews SET newstitle='" & newstitle & "', newsbody='" & newsbody & "', newsdate='" & newsdate & "' WHERE ID=" & ID
'Create an ADO connection and recordset object
Set connection=Server.CreateObject("ADODB.Connection")
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("news_data.mdb")
'Open the connection to our database
Connection.Open(sConnString)
'Execute the SQL
Connection.execute(SQL)
'Close the resources and free up space
connection.Close
Set connection=Nothing
Response.write "<div align='center'>Record Updated.</div>"
%>
</body>
</html>
wht change in this code so that the success message display on edit news page??
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head><title>News Management System - Update News</title>
</head>
<body>
<%
'declare you variables
Dim SQL, connection, recordset,msg
Dim sConnString, ID 'receive the id of the record passed through querystring
ID=request.querystring("ID")
'Declare the SQL statement that will query the database
SQL="SELECT * FROM latestNews WHERE ID=" & ID
'Create an ADO connection and recordset object
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("news_data.mdb")
'Open the connection to our database
Connection.Open(sConnString)
'Open the recordset object, execute the SQL statement
'and return the record with the id that was sent
recordset.Open SQL,connection
%>
<div align='center'>
<table width="370" border="0" cellspacing="0" cellpadding="0" align="center">
<tr align="left" valign="top">
<td>
<div align="center">
<p> </p>
<!-- start the html form -->
<form action="update_record.asp" method="post" name="form" id="frm" runat="server">
<table border="2" bordercolor="#CCCCFF" cellspacing="0" cellpadding="4">
<tr>
<td>
News Title</td>
<td>
<input id="txtAlpha" type="text" name="newstitle" value="<%= recordset("newstitle")%>" size="50"
class="cssborder" onkeyup="keyUP(event.keyCode)" onkeydown="return isAlpha(event.keyCode);"
onpaste="return false;" />
</td>
<td>
<span id="lblAlpha" style="color: Red; font-size: 10pt; font-family: Arial; visibility: hidden;">
* Only Alphabets</span>
</td>
</tr>
<tr>
<td valign="top">
News Text</td>
<td>
<textarea cols="50" rows="8" name="newsbody" class="cssborder"><% response.write recordset("newsbody") %></textarea></td>
</tr>
<tr>
<td>
News Date</td>
<td>
<input type="text" name="newsdate" value="<% response.write recordset("newsdate") %>" size="12" class="cssborder"></td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" name="id" value="<%=id%>">
<input type="hidden" name="ispostback" value="1">
<input type="submit" value="update" class="cssborder" />
<input type="reset" class="cssborder">
</td>
</tr>
</table>
</form>
</div>
<%
'close the connection and recordset objects
recordset.Close
Set recordset=Nothing
connection.Close
Set connection=Nothing
%>
</body>
</html>
the after submit edit news it will go to update_record.asp page the code is:
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head><title>News Management System - Updated News</title>
</head>
<body>
<%
'declare your variables
Dim SQL, connection, recordset, ID
Dim sConnString, newstitle, newsbody, newsdate
newstitle = request.form("newstitle")
newsbody = request.form("newsbody")
newsdate = request.form("newsdate")
ID=request.form("ID") 'receive the hidden form ID
'build the SQL - MAKE SURE YOUR CODE IS ON SAME LINE
SQL = "UPDATE latestNews SET newstitle='" & newstitle & "', newsbody='" & newsbody & "', newsdate='" & newsdate & "' WHERE ID=" & ID
'Create an ADO connection and recordset object
Set connection=Server.CreateObject("ADODB.Connection")
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("news_data.mdb")
'Open the connection to our database
Connection.Open(sConnString)
'Execute the SQL
Connection.execute(SQL)
'Close the resources and free up space
connection.Close
Set connection=Nothing
Response.write "<div align='center'>Record Updated.</div>"
%>
</body>
</html>
wht change in this code so that the success message display on edit news page??