この方法を使用し、「updatePanel」を使用してコントローラーを動的に変更できます。
ここでは、Usercontroller クラス名として「userControls_DeviceController」を使用します。
userControls_DeviceController FAN1;
userControls_DeviceController FAN2;
protected void Page_Load(object sender, EventArgs e)
{
FAN1 = (userControls_DeviceController)LoadControl("~/userControls/DeviceController.ascx");
saloon.Controls.Add(FAN1);
FAN2 = (userControls_DeviceController)LoadControl("~/userControls/DeviceController.ascx");
saloon.Controls.Add(FAN2);
}
また、ユーザーコントロールをカスタマイズするために、ページにタイマーを配置し、updatepanel を使用して指定したユーザーコントロールのプロパティを変更できます。
protected void Timer1_Tick(object sender, EventArgs e)
{
int counter = Convert.ToInt32(Session["c"]);
FAN1.SetDeviceIndex(counter);//here I change usercontrol picture FAN1
FAN2.SetDeviceIndex(counter);//here I change usercontrol picture FAN2
counter++;
if (counter == 4)//I have 4 picture to changing.
{
counter = 0;
}
Session["c"] = counter;
UpdatePanel1.Update();
}
お役に立てば幸いです...