H
Hai Nguyen
I would like to know I have two pages: consider page1, page2. Also, I have
code C# behind these two asp.net webforms. I code some methods in page1 and
I want page2 inherit what page1 has.
I know something has to deal with reference and inherit namespace and such.
Thanks
Page 1:
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
step1.Font.Bold = true; ->sth with this
StateList();
string clientIP1 = Request.UserHostAddress;
string strServername = Request.ServerVariables["SERVER_NAME"];
string strServerIP = Request.ServerVariables["LOCAL_ADDR"];
string strRemoteIP = Request.ServerVariables["REMOTE_ADDR"];
string[] str1 = Request.UserLanguages;
Response.Write(clientIP1+ "<br>");
Response.Write(strServername +"<br>");
Response.Write(strServerIP+"<br>");
Response.Write(strRemoteIP+"<br>");
for (int count = 0; count < str1.Length; count++)
{
Response.Write("User Language " + count +": " + str1[count] + "<br>");
}
}
}
IF I used this: Page 2: System.Web.UI.Page it's correct but i can not access any methods used in Page1
but if i use this Page 2: Page 1 there is an error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 272: //Update the statebox used ArrayList above
Line 273: //statebox = new DropDownList();
Line 274: statebox.DataSource = StateList;
Line 275: statebox.DataBind();
Line 276: }
code C# behind these two asp.net webforms. I code some methods in page1 and
I want page2 inherit what page1 has.
I know something has to deal with reference and inherit namespace and such.
Thanks
Page 1:
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
step1.Font.Bold = true; ->sth with this
StateList();
string clientIP1 = Request.UserHostAddress;
string strServername = Request.ServerVariables["SERVER_NAME"];
string strServerIP = Request.ServerVariables["LOCAL_ADDR"];
string strRemoteIP = Request.ServerVariables["REMOTE_ADDR"];
string[] str1 = Request.UserLanguages;
Response.Write(clientIP1+ "<br>");
Response.Write(strServername +"<br>");
Response.Write(strServerIP+"<br>");
Response.Write(strRemoteIP+"<br>");
for (int count = 0; count < str1.Length; count++)
{
Response.Write("User Language " + count +": " + str1[count] + "<br>");
}
}
}
IF I used this: Page 2: System.Web.UI.Page it's correct but i can not access any methods used in Page1
but if i use this Page 2: Page 1 there is an error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 272: //Update the statebox used ArrayList above
Line 273: //statebox = new DropDownList();
Line 274: statebox.DataSource = StateList;
Line 275: statebox.DataBind();
Line 276: }