StringBuilder strBuilder = new StringBuilder(); strBuilder.Append("<script language = 'javascript'>\n"); strBuilder.Append("function SetFocus()\n"); strBuilder.Append("{\n"); strBuilder.Append("document.forms.MobileWebForm1.txtBarCodeReader.focus();\n"); strBuilder.Append("document.forms.MobileWebForm1.txtBarCodeReader.select();\n"); strBuilder.Append("}\n"); strBuilder.Append("</script>\n"); RegisterStartupScript("Focus",strBuilder.ToString());Actually, the .select() call isn't necessary, AFAIK.
<body onload="SetFocus();">
(the body tag above would definitely be different in a real app, I just simplified it for the example - the important part is the "onload" part).