The Response object is a member of the HttpContext class, which is a member
of the Page class. That is why you can access it directly in your Page code.
Every HTTP Request causes ASP.Net to create an HttpContext class, which is
passed to the HttpHandler (in this case, an ASPX Page class). It contains
all the elements vital to reading the Request, forming and sending the
Response, and access to the Server. Fortunately, when a class is being used
by an HttpHandler (such as a Page), it can access the entire contents of the
HttpContext, by calling upon System.Web.HttpContext.Current. Among these
static members is the Response. So, in your class, you can refer to
System.Web.HttpContext.Current.Response.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"hansiman" <ha***@hotmail.com> wrote in message
news:d3********************************@4ax.com...
When I use the sub code below directly in the code behind page it
works. However, if I move the code into a sub and place the sub in a
class file I get a building error "Name 'Response' is not declared."
I figure it has to do with the imports .... but I have tried both
system.web.ui and a couple of others...
Please help.
/morten
Public Sub addCookie(ByVal sName As String, ByVal sValue As String,
ByVal dExpiry As DateTime)
Dim cookie As HttpCookie = New HttpCookie(sName)
cookie.Value = sValue
cookie.Expires = dExpiry
Response.Cookies.Add(cookie)
End Sub