Click here to Skip to main content
15,920,956 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I typed System.Web.UI.Page.Request but the System.Web.UI.Page. only has such 3 properties: CreateHtmlTextWriterFromType, Equals and ReferenceEquals). What is the reason for it? Thanks.
Posted

try like this..

system.web.ui.page is a type .
. you should create instance to access the members.

C#
new  System.Web.UI.Page().Request



C#
protected void Page_Load(object sender, EventArgs e)
      {
          if (!Page.IsPostBack)
          {
            Page.Request // here Page refers the current Instance..
          }
      }
 
Share this answer
 
Comments
[no name] 9-Jan-14 13:29pm    
Got an additional Q - when I put
string route = Page.Request["routeID"].ToString();
in Page_Load() and run it, got NullReferenceException - Object reference not set to an instance of an object. How to create an object here? Thanks.
Karthik_Mahalingam 10-Jan-14 0:04am    
routeID is the query string parameter??
That is the difference between class properties/methods and instance properties/methods.
class properties/mnethods can be accessed simply via the class, while instance properties/methods need an instance (new) of that class.

Request[^] is an non static property of Page and thus needs an instance of Page in order to be accessible.

Cheers!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900