468,252 Members | 1,480 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,252 developers. It's quick & easy.

response redirect help

hello i am trying to use a response redirect statment to show a message
upon deletion of a record from a database. my database is ran though a
page with a table with a delete option on the side. when the delete
link is clicked, the script loads a page that has a immediate
response.redirect in it. here is that code for the delete_response
page.

<% Option Explicit %>
<!--#include virtual="\06Winter/levini/database/adovbs.inc"-->
<!--#include file="DatabaseConnect2.asp"-->
<HTML>
<center>
<% Dim objRS, bolFound, CustID, intCustID
CustID = Request.querystring("CustID")

intCustID = CInt(request("CustID"))

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "tblCustomerData", objConn, adOpenForwardOnly,
adLockOptimistic, adCmdTable
bolFound = False

'look for CustID in table
Do While Not (objRS.EOF OR bolFound)
If (StrComp(objRS("CustID"), CustID, vbTextCompare) = 0) Then
BolFound = True
Else
objRS.MoveNext
End If
Loop
objRS.Delete
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
response.redirect "ListCustomers.asp?StatusMessage=Customer ID "
& request("CustID") & " successfully deleted."

%>
</BODY>
</HTML>

what i want to do is put a message on my mainpage that displays the
message from the response.redirect prompt. how do i create a message
from reading the querystring

thanx for the help

isaac

Feb 7 '06 #1
10 1902
Issac,

Just a thought and this is an easy way of doing this, in your
querystring you may want to add a varialbe such as:

response.redirect "ListCustomers.asp?StatusMessage=Customer ID " &
request("CustID") & "&delcust=1"

Then on your page that displays the customers you can put a simple
little response.write that is only activated if the variable delcust =
1. Example
<%
Dim DelCust
DelCust = 0
DelCust = Request.QueryString("delcust")

If DelCust = 1 Then
Response.Write "Customer Deleted"

Else

Just something that I have used in the past that works very easy.

Now if you want to do an alert box that is another story

isaac2004 wrote:
hello i am trying to use a response redirect statment to show a message
upon deletion of a record from a database. my database is ran though a
page with a table with a delete option on the side. when the delete
link is clicked, the script loads a page that has a immediate
response.redirect in it. here is that code for the delete_response
page.

<% Option Explicit %>
<!--#include virtual="\06Winter/levini/database/adovbs.inc"-->
<!--#include file="DatabaseConnect2.asp"-->
<HTML>
<center>
<% Dim objRS, bolFound, CustID, intCustID
CustID = Request.querystring("CustID")

intCustID = CInt(request("CustID"))

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "tblCustomerData", objConn, adOpenForwardOnly,
adLockOptimistic, adCmdTable
bolFound = False

'look for CustID in table
Do While Not (objRS.EOF OR bolFound)
If (StrComp(objRS("CustID"), CustID, vbTextCompare) = 0) Then
BolFound = True
Else
objRS.MoveNext
End If
Loop
objRS.Delete
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
response.redirect "ListCustomers.asp?StatusMessage=Customer ID "
& request("CustID") & " successfully deleted."

%>
</BODY>
</HTML>

what i want to do is put a message on my mainpage that displays the
message from the response.redirect prompt. how do i create a message
from reading the querystring

thanx for the help

isaac


Feb 7 '06 #2
hey thanx for the help but that isnt working properly, where in my code
would i put the script for the mesage

Feb 7 '06 #3
Watch For Word Wrap!

Well a portion of your ListCustomers.asp page would be helpful, however
here is the best case scenario.

Your redirect line in delete_response page. I have always found it best
to enter in the exact path of the page from the webroot.

response.redirect "/ListCustomers.asp?StatusMessage=Customer ID " &
request("CustID") & "&delcust=1"

Your Listcustomers.asp page, Call and set the querystring early on in
the script

Dim DelCust
DelCust = Request.QueryString("delcust")

Just before you call your loop to display your customers:

If DelCust = 1 Then
response.write "Customer Removed"
End If

Feb 7 '06 #4
One other thing i noticed, change

response.redirect "/ListCustomers.asp?StatusMessage=Customer ID " &
request("CustID") & "&delcust=1"

to

response.redirect "/ListCustomers.asp?StatusMessage=Customer ID " &
CustID & "&delcust=1"

Feb 7 '06 #5
thanks for the help it works now yay

Feb 7 '06 #6
thanks for the help it works now yay

Feb 7 '06 #7
Your welcome. Happy Scripting

Feb 7 '06 #8
oh wait one more thing it works i just want to tweak the message a
little so it says

CustID (the actual number of the Cust ID) deleted successfully.

how would i do this

Feb 7 '06 #9
oh wait one more thing it works i just want to tweak the message a
little so it says

CustID (the actual number of the Cust ID) deleted successfully.

how would i do this

Feb 7 '06 #10
OK, from what i can tell from your querystring the custid is sent back
to the listcustomers.asp. You might want to declare another variable
for the deletedcustomer as you don't want to get CustID mixed with the
actually CustID that you call later.

For example, here is your redirect line and your listcustomers line

response.redirect "/ListCustomers.asp?StatusMessage=" & CustID &
"&delcust=1"

ListCustomers Code

Dim DelCust
Dim DelCustID
DelCust = Request.QueryString("delcust")
DelCustID = Request.QueryString("StatusMessage")

If DelCust = 1 Then
response.write "Customer " & DelCustID & " Has Been Successfully
Removed"
End If

Personally I like to use red, so people see that clearly.
If DelCust = 1 Then
response.write "<font color=#FF0000>Customer " & DelCustID & " Has
Been Successfully Removed<font>"
End If

Feb 7 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Justin | last post: by
1 post views Thread by Sospeter | last post: by
13 posts views Thread by Tim | last post: by
4 posts views Thread by JIM.H. | last post: by
10 posts views Thread by Niggy | last post: by
1 post views Thread by Lionel | last post: by
1 post views Thread by Kevin Blount | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.