|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
RE: Response is not available in this contextYour class must be under APP_Code as I can guess, that is why response is not available. You don't need to inherit from System.Web.UI.Page. Hope that helps. Show quoteHide quote "Joe Stateson" wrote: > 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. > > 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 > > > ok, it finally recognized "Response" and compiled. Unfortunately, it wont > run and gives me the error message "Response is not available in this > context" > > 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 > ======= > 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"); > } > > > Regards > Joseph > > >
Problem creating TemplateFields in DetailsView dynamically
{0:c} causes input string not in correct format exception GridView is making two of each column 2nd Post - {0:c} causes deletes to fail! Rendering a GridView Updating SelectedIndex after delete Making an entire column visible/not visible. Having a column with a checkbox where when the checkbox changes, it updates a table. programmatically create a gridview In a GridView i have a new dataset i want to show in it... |
|||||||||||||||||||||||