Friday, August 15, 2008

How to Use Response Object in a Class

If you try to use


Response.Write(MyString);

Method for example in a class you will receive an error telling you that the Response Object is not available in this context.

In order to use the Response Object in a class without having this error, instead of writing

Response.Write(MyString);

write this

HttpContext.Current.Response.Write(MyString);

Or you can use any method of the Response Object.

And don't forget to write Using System.Web in the top of the class.

Hire Me

Follow me on Facebook

Follow me

Do you find this Blog helpful?

Follow by Email

About Me

My Photo
Expert Senior Software Developer

Microsoft Business Card