Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Response.Write in custom class

How can I call Response.Write method in a custom class. It works in my aspx page but I can not invoke it in a custom class.

Please help.

Jen

Jen
Tuesday, March 15, 2005

How can I call Response.Write method in a custom class. It works in my aspx page but I can not invoke it in a custom class.

If I want to see some output on the browser, I add a Label in my custom class.  Use label.Text = "what ever I want";
You can display the text on your form or you can use the label.text in Resonse.write method of your asp file.

Simon Rez
Tuesday, March 15, 2005

System.Web.HttpContext.Current.Response.Write().

But since ASPX page output is normally generated in the Render phase, you may not get the result you're expecting if your custom class does this at the wrong time.

Updating the Text property of a Literal or Label control as suggested by Simon might give you more control.

Joe
Tuesday, March 15, 2005

Have your class return a string from a property and then have your aspx display the result of the method call.

Sassy
Tuesday, March 15, 2005

Actually, I am trying to launch a new window inside the custom class using the following code:

string script = String.Format("<script>window.open('{0}')</script>",fullPath);
                
Response.Write(script);

Jen
Wednesday, March 16, 2005

But the response.write method keeps failing on me. :==(

Jen
Wednesday, March 16, 2005

Failing how?

Joe
Wednesday, March 16, 2005

*  Recent Topics

*  Fog Creek Home