I am trying to access variable from one class to another. I tried help from this question but it was on other way. I have a base class as following:
public class BasePage : System.Web.UI.Page
{
public int MemberUserId
{
get
{
MembershipUser user = Membership.GetUser();
if (user != null)
{
string memberUserId = user.ProviderUserKey.ToString();
CustomerBL clientsBL = new CustomerBL ();
Customers customer = CustomerBL .GetCustomer(memberUserId);
int customerId = customer .CustomerId;
return customerId;
}
return 0;
}
}
}
I want to get customerId to this class as following :
public partial class showCustomer : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
LoadCustomerProfile();
}
}
LoadCustomerProfile()
{
BasePage basePage;
int customerId = basePage.customerId; //intellisense is not showing option of customerId
}
}
when I type basePage.customerId, intellisense does not show customerId and gives error when i forcefully type it. I will be grate full if anyone help me out. :)
You haven't created a customerId
property. You've created a MemberUserId
property.
That said, your code would still be invalid as you've declared the basePage
local variable, but haven't assigned a value to it. Are you sure you don't just want:
int customerId = MemberUserId;
i.e. asking this
?
See more on this question at Stackoverflow