dayrenderイベントでコントロールを追加した後、コントロールを後で見つける方法はありますか?私は試しましたasp.netカレンダーコントロール内でコントロールを検索する方法
calendar.FindControl("lblSample")
しかし成功しません。ここで
は私のコードの一部は、より明確にすることです:イベントとページの負荷を完全にレンダリングするprotected void calSample_DayRender(object sender, DayRenderEventArgs e)
{
Label lblSample = new Label();
lblSample.ID = "lblSample";
lblSample.Text = "Sample";
e.Cell.Controls.Add(lblSample);
}
一日を過ごした後、私は私がしようとすると、バック
をコントロールを取得し、リンクボタンのイベントを持っていますprotected void lbtnSave_Click(object sender, EventArgs e)
{
//Not working
Label lblSample = calSample.FindControl(lblSample);
//Also can't get to work, this was using Ross' suggestion and the recursive find function he wrote about. I'm probably just not using it correctly.
Label lblSample = ControlFinder.FindControl<Label>(calSample, "lblSample");
}
を取得 'FindControl'は、再帰的に検索するつもりはありません。 –
複数のレイヤーを再帰的に処理する必要があります。あなたのフォームにあなたのコントロールを持つasp:Panelがある場合は、Form => Panel => Controlをナビゲートする必要があります。 – StuartLC
http://stackoverflow.com/questions/2209854/find-all-child-controls-of-specific-type-using-enumerable-oftypet-or-linq – abatishchev