Saturday, 17 August 2013

passing values between separate classes

passing values between separate classes

I have two separate classes: 1 In a tbIndexUI.aspx.cs page and the other
in a regular.cs class file. I would like to pass two data members from the
regular .cs class file to the .aspx page, however every time the
"Page_Load" method fires it resets all the values that were previously
passed. I tried commenting out everything in "Page_Load" and I event went
as far as removing the method all together, but the parameter values are
still being reset.
Is there a way to pass these values to and maintain them? Any examples
would be extremely helpful as I am lost. I looked at this [example] but
was unsuccessful.
Code for my aspx.cs page
public partial class tbIndexUI : System.Web.UI.UserControl
{
private int _numOfCols = 0;
private int itemsPerCol = 0;
public int numColumns
{
set
{
_numOfCols = value;
}
}
public int itemsPerColumn
{
set
{
_itemsPerCol = value;
}
}
public static void passData(int numOfCol, int itemsPerCol)
{
numColumns = numOfCol;
itemsPerColumn = itemsPerCol;
}
}
Code for my regular class process.cs
void sendInformation()
{
tbIndexUI.passData(numOfCols, itemsPerCol);
}

No comments:

Post a Comment