パブリック プロパティまたは関数を作成して、ユーザー コントロールの機能を公開し、必要なことを実行したり、希望どおりに動作させたりする必要があります。たとえば、あなたの場合、ユーザーコントロールに次のようなプロパティを含めることができます(関数を実行することもできます):
public List<string> SomeValues
{
get
{
// return null if checkbox is not checked, you could just as easily return an empty list.
List<string> lst = null;
if (yourCheckBox.Checked)
{
lst = new List<string>();
// You could have something that iterates and find your controls, remember you
// are running this within your user control so you can access all it's controls.
lst.Add(yourTextBox1.Text);
lst.Add(yourTextBox2.Text);
lst.Add(yourTextBox3.Text);
// etc...
}
return lst;
}
}
次に、ページでユーザー コントロールにアクセスし、このプロパティを呼び出して値を取得できます。
// assuming you defined your usercontrol with the 'yourUserControl' ID
List<string> lst = yourUserControl.SomeValues;
重要なのは、ユーザーコントロールで必要なものを公開するだけなので、それを使用しているものは何でも、その詳細や実装について知る必要はありません。他のコントロールと同じように使用できるはずです。