Hope this comes out clear enough.
I am new to this all.
I have a asp.net and c# project, in the app_code i have a class userInterface.cs, what i need to do is the folowing:
In that class i need to get a certain page
NewPage.aspx
, and to modify some asp elements on that page.
Currently i have this:
Page p = (Page)HttpContext.Current.Handler;
Not sure what else i need in order to get the page. the page i want is called NewPage.aspx.
I will appreciated any answer.
even something to google in order to find will be great. i dont know were to start from....
You may be able to access the page through HttpContext, but that's probably not a good approach. As other posters have noted, just use a method and pass in a reference to the control.
To answer your question though, you can try something like this:
if (HttpContext.Current.Handler is Page)
{
Page currentPage = (Page)HttpContext.Current.Handler;
if (currentPage != null)
{
//depending on where the control is located, you may need to use recursion
GridView gridView = currentPage.FindControl("GridView1");
}
}
I must reiterate that this probably isn't a good approach though, for a myriad of reasons. I did want someone to answer your actual question though, so there it is.