I get that error message when trying to do a "Response.write ()". I undoubtedly set up my classes wrong. My workaround is to put the offending code in each codebehind page. I would like to put the code in my "constant class" so it can be called as a function by any page. Details follow:
I added a gridview print routine to my dotnet 2 app. It works fine after
googling why it didnt work for an hour or more. Since I got several grids on various pages I thought I would add it to my "constant class" which all my codebehinds have and I put all my common code in it.
ok, it finally recognized "Response" and compiled. Unfortunately, it wont
run and gives me the error message "Response is not available in this
context" at the line "Response.Clear ()"
There is something wrong with how I defined my class I suspect. All I
wanted to do was to call the "print" function from any of my pages and not have to put the print function in each C# page. I am doing something wrong, yet all my other functions get called and work ok (they do not have "response") .
I call the print function as outlined below
Regards
Joseph
I added a gridview print routine to my dotnet 2 app. It works fine after
googling why it didnt work for an hour or more. Since I got several grids on various pages I thought I would add it to my "constant class" which all my codebehinds have and I put all my common code in it.
Code:
namespace Training { .. public class ConstClass { ... public void print(GridView gv, strFilename) { Response.Clear(); ..etc.. } ... } } the above would not compile until I added System.Web.UI.Page as in public class ConstClass : System.Web.UI.Page
run and gives me the error message "Response is not available in this
context" at the line "Response.Clear ()"
There is something wrong with how I defined my class I suspect. All I
wanted to do was to call the "print" function from any of my pages and not have to put the print function in each C# page. I am doing something wrong, yet all my other functions get called and work ok (they do not have "response") .
I call the print function as outlined below
Code:
protected void Page_Load(object sender, EventArgs e) { if (null == Session["cUsefulFunctions"]) Session["cUsefulFunctions"] = new ConstClass(Session); cUsefulFunctions = (ConstClass)Session["cUsefulFunctions"]; ..etc.. protected void btnPrint_Click(object sender, EventArgs e) { cUsefulFunctions.print(gv4needed, "needed.xls"); }
Joseph
Comment