1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
private void Page_Load(object sender, EventArgs e)
{
//Hier gibt man die gewünschte TextBox an.
SetFocus(TextBox);
}
private void SetFocus(Control ctrl)
{
StringBuilder sb = new StringBuilder(100);
sb.Append("<script language=\"javascript\">\r\n");
sb.Append("<!--\r\n");
sb.Append("document.getElementById('");
sb.Append(ctrl.ClientID);
sb.Append("').focus();\r\n");
sb.Append("-->\r\n");
sb.Append("</script>\r\n");
this.Page.RegisterStartupScript("SetFocus", sb.ToString());
}
|