怎样在执行服务器事件后 获取 鼠标光标
一个页面,刚打开的时候光标停留在TextBox1上,然后执行TextBox1_TextChanged,保存数据后,
我还是需要光标停留在TextBox1上,怎么写?
我的源码:(aspx)
<body >
<form id="form1" runat="server" >
asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" OnTextChanged="TextBox1_TextChanged" OnLoad="TextBox1_Load" ></asp:TextBox><div align=center>
<table cellspacing="1" bgcolor="black" border="0" width="800" height="500">
<tr bgColor="#f1eff8">
<td width="100" >xx1</td>
<td width="200">
<asp:Label ID="Label1" runat="server" ></asp:Label></td>
<td rowspan=4 bgcolor=white align=left height="500" width="500" >
<div align=center>
<asp:Label ID="Label5" runat="server" Font-Size="XX-Large" ForeColor="SandyBrown" Visible=false></asp:Label></div>
<asp:Image ID="Image1" runat="server" Width="500" Height="500" Visible=false /></td>
</tr>
<tr bgColor="#f1eff8">
<td>xx2</td>
<td>
<asp:Label ID="Label2" runat="server" ></asp:Label></td>
</tr>
<tr bgColor="#f1eff8">
<td>xx3</td>
<td>
<asp:Label ID="Label4" runat="server"></asp:Label>
</td></tr>
<tr bgColor="#f1eff8">
<td>xx4</td>
<td>
<asp:Label ID="Label3" runat="server"></asp:Label></td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
.CS页面
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.TextBox1.Focus();
}
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
string tt = TextBox1.Text;
string sql = "select * from table where tt='" + tt + "'";
DataTable dt = Table(sql);
if (dt.Rows.Count > 0)
{
Label1.Text = dt.Rows[0][0].ToString();
Label2.Text = dt.Rows[0][1].ToString();
Label3.Text = dt.Rows[0][2].ToString();
Label4.Text = dt.Rows[0][3].ToString();
if (dt.Rows[0][4].ToString() != "0")
{
Image1.Visible = true;
Label5.Visible = false;
Image1.ImageUrl = dt.Rows[0][4].ToString();
}