日期:2014-05-18  浏览次数:20483 次

TextBox 文本选中问题
请问,服务器端控件中的文本怎样默认选中,例如:
<asp:TextBox ID = "name" Text="请输入名称" runat="server"></asp:TextBox>
让Text="请输入名称" 中的“请输入名称”默认选中

------解决方案--------------------
在属性里找吧,可以选择默认选中次序和按TAB的选顺序等
------解决方案--------------------
<form id="form1" runat="server" defaultbutton="btnQuery" defaultfocus="txtUsername">
设置默认文本框和默认按钮
------解决方案--------------------
onfocus="javascript:this.select()"
------解决方案--------------------
楼上的回答是没有看清楚问题
这个需要弄个js来做
onfocus="this.selected=true;"
------解决方案--------------------
抱歉我的方法没写对,可以参考3楼的
------解决方案--------------------
HTML code

<body onload="document.getElementById('txt').focus()" >
<asp:TextBox ID='txt' runat="server" onfocus='this.select();' Text="sdfjsklfjlksd"></asp:TextBox>