我正在使用 SQL 查询动态创建按钮:
private void createPagingButtons(DateTime firstDayofWeek, DateTime lastDayofWeek)
{
int i = 1;
//get query that holds all of the names for a date range
SqlDataReader returnedQuery = getDefaultUser(firstDayofWeek, lastDayofWeek);
while (returnedQuery.Read())
{
string buttonName = returnedQuery["Person"].ToString();
string[] splitString = buttonName.Split('(');
Button btn = new Button();
btn.ID = buttonName;
btn.Click += new EventHandler(btn_Click);
btn.Text = splitString[0];
btn.Width = Convert.ToInt32(splitString[0].Length)*9;
btn.CssClass = "dynamicButtons";
pagingPanel.Controls.Add(btn);
i++;
}
}
因此,我没有它们的特定名称,它们在 ASP.NET 端是静态的。在回发时,我想 button.focus() 被点击的那个。
我如何实现这一目标?