Results 1 to 7 of 7

Thread: Calling response.redirect from within a class *RESOLVED*

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982

    Calling response.redirect from within a class *RESOLVED*

    I want to use
    VB Code:
    1. response.redirect("somepage.aspx")
    from within a class.
    It is giving me an error
    Name 'response' is not declared
    I have added the line
    VB Code:
    1. imports system.web.HttpResponse
    but that doesn't help.
    Last edited by davidrobin; May 27th, 2004 at 09:05 AM.


    Things I do when I am bored: DotNetable

  2. #2
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    You can't use response.redirect from an external class, check this post for more info.

  3. #3
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    You most certainly can redirect the page from an external class. You simply pass a reference to the page (or its HTTPContext and call the htttpcontext.response.redirect).

    VB Code:
    1. Dim G As myExternalClass
    2. G.myexternalFunction(x, y, Me.Page)
    3.  
    4.  
    5. ....
    6. Public MyExternalClass
    7.  
    8.  Public Function myExternalFunction (x as Integer, y As Integer, refPage As Page)
    9. If X>Y Then Response.Redirect("http://www.google.com")
    10. End Function
    Last edited by nemaroller; May 27th, 2004 at 06:47 AM.

  4. #4
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    My Apologies but a similar method was described in the thread i linked wasn't it?

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Yes, and I posted the reference passing method for that too.

    In that post, the user may also have security access permission errors however, which they would have to solve using assertions.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Thanks for your replies.

    I keep getting 'page is undefined' errors on the following line
    VB Code:
    1. Sub New(ByRef RefPage As page)
    Last edited by davidrobin; May 27th, 2004 at 09:33 AM.


    Things I do when I am bored: DotNetable

  7. #7
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    The type you are trying to pass is:
    System.Web.UI.Page

    Make sure you have a ref to the System.Web assembly and use the full qualified type name or add a namespace to System.Web.UI.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width