PDA

Click to See Complete Forum and Search --> : Calling response.redirect from within a class *RESOLVED*


davidrobin
May 27th, 2004, 04:55 AM
I want to use
response.redirect("somepage.aspx") from within a class.
It is giving me an error
Name 'response' is not declared
I have added the lineimports system.web.HttpResponse but that doesn't help.

Fishcake
May 27th, 2004, 06:27 AM
You can't use response.redirect from an external class, check this post (http://www.vbforums.com/showthread.php?threadid=263592) for more info.

nemaroller
May 27th, 2004, 06:44 AM
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).


Dim G As myExternalClass
G.myexternalFunction(x, y, Me.Page)


....
Public MyExternalClass

Public Function myExternalFunction (x as Integer, y As Integer, refPage As Page)
If X>Y Then Response.Redirect("http://www.google.com")
End Function

Fishcake
May 27th, 2004, 06:50 AM
My Apologies but a similar method was described in the thread i linked wasn't it?

nemaroller
May 27th, 2004, 07:01 AM
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.

davidrobin
May 27th, 2004, 09:05 AM
Thanks for your replies.

I keep getting 'page is undefined' errors on the following lineSub New(ByRef RefPage As page)

Lethal
May 27th, 2004, 11:25 AM
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.