response redirect help

I

isaac2004

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
 
N

nvanhaaster

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
 
I

isaac2004

hey thanx for the help but that isnt working properly, where in my code
would i put the script for the mesage
 
N

nvanhaaster

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
 
N

nvanhaaster

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"
 
I

isaac2004

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
 
I

isaac2004

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
 
N

nvanhaaster

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top