我有两个单独的类:1 在 tbIndexUI.aspx.cs 页面中,另一个在 regular.cs 类文件中。我想将两个数据成员从常规的 .cs 类文件传递到 .aspx 页面,但是每次“Page_Load”方法触发它都会重置之前传递的所有值。我尝试将“Page_Load”中的所有内容都注释掉,并且我的事件甚至一起删除了该方法,但参数值仍在被重置。
有没有办法将这些值传递给并维护它们?当我迷路时,任何例子都会非常有帮助。我查看了这个[example]但没有成功。
我的 aspx.cs 页面的代码
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;
}
}
我的常规课程 process.cs 的代码
void sendInformation()
{
tbIndexUI.passData(numOfCols, itemsPerCol);
}