response redirect help

Discussion in 'ASP General' started by isaac2004, Feb 7, 2006.

  1. isaac2004

    isaac2004 Guest

    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
     
    isaac2004, Feb 7, 2006
    #1
    1. Advertising

  2. isaac2004

    Guest

    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, 2006
    #2
    1. Advertising

  3. isaac2004

    isaac2004 Guest

    hey thanx for the help but that isnt working properly, where in my code
    would i put the script for the mesage
     
    isaac2004, Feb 7, 2006
    #3
  4. isaac2004

    Guest

    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, 2006
    #4
  5. isaac2004

    Guest

    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, 2006
    #5
  6. isaac2004

    isaac2004 Guest

    thanks for the help it works now yay
     
    isaac2004, Feb 7, 2006
    #6
  7. isaac2004

    isaac2004 Guest

    thanks for the help it works now yay
     
    isaac2004, Feb 7, 2006
    #7
  8. isaac2004

    Guest

    Your welcome. Happy Scripting
     
    , Feb 7, 2006
    #8
  9. isaac2004

    isaac2004 Guest

    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
     
    isaac2004, Feb 7, 2006
    #9
  10. isaac2004

    isaac2004 Guest

    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
     
    isaac2004, Feb 7, 2006
    #10
  11. isaac2004

    Guest

    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, 2006
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman
    Replies:
    2
    Views:
    8,024
    Charles A. Lackman
    Jan 11, 2006
  2. Matthew Wieder

    Response.Write and Response.Redirect

    Matthew Wieder, Jul 17, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    709
    Kevin Spencer
    Jul 17, 2003
  3. =?Utf-8?B?VHJveQ==?=

    Response.redirect does not redirect from .aspx page

    =?Utf-8?B?VHJveQ==?=, Oct 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,262
    Srowe1975
    Oct 15, 2008
  4. Sal
    Replies:
    1
    Views:
    577
  5. Ron Howard
    Replies:
    2
    Views:
    529
    Ron Howard
    Aug 11, 2004
Loading...

Share This Page