日期:2014-05-20  浏览次数:20503 次

c#.asp中自定义控件如何得到焦点
persondefault.aspx上放了一个自定义控件DGliuyan.ascx
DGliuyan.ascx中有个TextBox,一个Button!
现在我单击Button,使TextBox得到焦点!
Page.RegisterStartupScript( " ", " <script> document.form(0).TextBox.focus(); </script> ");
无效!
用C#.ASP如何实现?


------解决方案--------------------
http://blog.csdn.net/chsword/archive/2007/02/08/1505073.aspx

<script type= "text/javascript ">
var focusControl = document.forms[ " <%=page.Form.ClientID %> "].elements[ " <%=yourctrl.ClientID %> "];
if (focusControl.type != "hidden " && !focusControl.disabled)
{
focusControl.focus();
}
</script>