这是一个不错的选择:
使用UpdatePanel的页面。里面是ListView。它有1个TextBox。当用户单击按钮时,我将ListView的InsertItemPosition设置为top。
问:如何将焦点设置在TextBox上?
答案 0 :(得分:0)
如果您在页面上有ScriptManager
控件,则可以将其用于SetFocus
控件的TextBox
。您需要在按钮点击事件中的代码中执行此操作。
编辑:这应该允许您访问InsertItemTemplate中的TextBox控件。 注意:您需要将FindControl
方法中的控件名称更改为TextBox
中InsertItemTemplate
的名称。
示例:强>
TextBox tb = ListView1.InsertItem.FindControl("tbName") as TextBox;
if (tb != null)
{
ScriptManager1.SetFocus(tb);
}