<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<SCRIPT language="JavaScript">
function enterkey()
{
if(event.keyCode==13)
{
WebForm1.Button1.click();
}
}
function movefocus(tbName)
{
if(event.keyCode==13)
{
tbName.focus();
}
}
</SCRIPT>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
TextBox1.Attributes["onkeydown"] = "javascript:movefocus(WebForm1.TextBox2)";
TextBox2.Attributes["onkeydown"] = "javascript:movefocus(WebForm1.TextBox3)";
TextBox3.Attributes["onkeydown"] = "javascript:movefocus(WebForm1.TextBox4)";
TextBox4.Attributes["onkeydown"] = "javascript:movefocus(WebForm1.Button1);enterkey()";
//Button1.Attributes["onkeydown"] = "javascript:enterkey()";
}
private void Button1_Click(object sender, System.EventArgs e)
{
Label5.Text = "演示过程结束.<br>由于时间问题,没有做到更好,有兴趣的朋友一起共同搞定啊,别忘记共享给大家";
}
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" onkeydown="if(event.keyCode==13) return false;" onload="WebForm1.Button1.focus();WebForm1.TextBox1.focus()">
<form id="WebForm1" method="post" runat="server">
<asp:textbox id="TextBox1" style="Z-INDEX: 101; LEFT: 11px; POSITION: absolute; TOP: 29px" runat="server"
Width="94px"></asp:textbox>
<br>
<asp:textbox id="TextBox2" style="Z-INDEX: 102; LEFT: 9px; POSITION: absolute; TOP: 70px" runat="server"
Width="93px"></asp:textbox>
<br>
<asp:textbox id="TextBox3" style="Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 112px" runat="server"
Width="91px"></asp:textbox>
<br>
<asp:textbox id="TextBox4" style="Z-INDEX: 104; LEFT: 6px; POSITION: absolute; TOP: 150px" runat="server"
Width="91px"></asp:textbox>
<br>
<asp:button id="Button1" style="Z-INDEX: 105; LEFT: 15px; POSITION: absolute; TOP: 195px" runat="server"
Text="Button1"></asp:button>
<br>
<asp:label id="Label1" style="Z-INDEX: 106; LEFT: 115px; POSITION: absolute; TOP: 32px" runat="server">TextBox1</asp:label>
<asp:Label id="Label2" style="Z-INDEX: 107; LEFT: 109px; POSITION: absolute; TOP: 73px" runat="server">TextBox2</asp:Label>
<asp:Label id="Label3" style="Z-INDEX: 108; LEFT: 106px; POSITION: absolute; TOP: 117px" runat="server">TextBox3</asp:Label>
<asp:Label id="Label4" style="Z-INDEX: 109; LEFT: 107px; POSITION: absolute; TOP: 155px" runat="server">TextBox4</asp:Label>
<asp:Label id="Label5" style="Z-INDEX: 110; LEFT: 16px; POSITION: absolute; TOP: 240px" runat="server"
ForeColor="Red"></asp:Label>
<asp:Label id="Label6" style="Z-INDEX: 111; LEFT: 190px; POSITION: absolute; TOP: 48px" runat="server"
Width="512px">这是一个比较完美的解决方案<br>按回车键光标自动移动到下一个TextBox,最后执行Button的OnClick事件<br>重要的是利用JavaScript<br><br>缺点有2个:<br>Page_load时,光标不能自动定位在TextBox1<br>当光标定位到Button1时,需要再按一次回车键才能触发Button1_OnClick事件</asp:Label></form>
</body>
</HTML>
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<SCRIPT language="JavaScript">
function enterkey()
{
if(event.keyCode==13)
{
WebForm1.Button1.click();
}
}
function movefocus(tbName)
{
if(event.keyCode==13)
{
tbName.focus();
}
}
</SCRIPT>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
TextBox1.Attributes["onkeydown"] = "javascript:movefocus(WebForm1.TextBox2)";
TextBox2.Attributes["onkeydown"] = "javascript:movefocus(WebForm1.TextBox3)";
TextBox3.Attributes["onkeydown"] = "javascript:movefocus(WebForm1.TextBox4)";
TextBox4.Attributes["onkeydown"] = "javascript:movefocus(WebForm1.Button1);enterkey()";
//Button1.Attributes["onkeydown"] = "javascript:enterkey()";
}
private void Button1_Click(object sender, System.EventArgs e)
{
Label5.Text = "演示过程结束.<br>由于时间问题,没有做到更好,有兴趣的朋友一起共同搞定啊,别忘记共享给大家";
}
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" onkeydown="if(event.keyCode==13) return false;" onload="WebForm1.Button1.focus();WebForm1.TextBox1.focus()">
<form id="WebForm1" method="post" runat="server">
<asp:textbox id="TextBox1" style="Z-INDEX: 101; LEFT: 11px; POSITION: absolute; TOP: 29px" runat="server"
Width="94px"></asp:textbox>
<br>
<asp:textbox id="TextBox2" style="Z-INDEX: 102; LEFT: 9px; POSITION: absolute; TOP: 70px" runat="server"
Width="93px"></asp:textbox>
<br>
<asp:textbox id="TextBox3" style="Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 112px" runat="server"
Width="91px"></asp:textbox>
<br>
<asp:textbox id="TextBox4" style="Z-INDEX: 104; LEFT: 6px; POSITION: absolute; TOP: 150px" runat="server"
Width="91px"></asp:textbox>
<br>
<asp:button id="Button1" style="Z-INDEX: 105; LEFT: 15px; POSITION: absolute; TOP: 195px" runat="server"
Text="Button1"></asp:button>
<br>
<asp:label id="Label1" style="Z-INDEX: 106; LEFT: 115px; POSITION: absolute; TOP: 32px" runat="server">TextBox1</asp:label>
<asp:Label id="Label2" style="Z-INDEX: 107; LEFT: 109px; POSITION: absolute; TOP: 73px" runat="server">TextBox2</asp:Label>
<asp:Label id="Label3" style="Z-INDEX: 108; LEFT: 106px; POSITION: absolute; TOP: 117px" runat="server">TextBox3</asp:Label>
<asp:Label id="Label4" style="Z-INDEX: 109; LEFT: 107px; POSITION: absolute; TOP: 155px" runat="server">TextBox4</asp:Label>
<asp:Label id="Label5" style="Z-INDEX: 110; LEFT: 16px; POSITION: absolute; TOP: 240px" runat="server"
ForeColor="Red"></asp:Label>
<asp:Label id="Label6" style="Z-INDEX: 111; LEFT: 190px; POSITION: absolute; TOP: 48px" runat="server"
Width="512px">这是一个比较完美的解决方案<br>按回车键光标自动移动到下一个TextBox,最后执行Button的OnClick事件<br>重要的是利用JavaScript<br><br>缺点有2个:<br>Page_load时,光标不能自动定位在TextBox1<br>当光标定位到Button1时,需要再按一次回车键才能触发Button1_OnClick事件</asp:Label></form>
</body>
</HTML>
解决方案 »
- 淘宝开放API里怎么取sessionKey啊 有谁知道啊 急啊
- [史上最菜星高分求助]sl中Gridview多行表头原样导出Excel,期待牛人
- 急!文件XX.html”正由另一进程使用,因此该进程无法访问该文件
- 水晶 报表 打印次数限制 ,改注册表没有用
- 极度菜鸟问题,高手们帮小弟解决下,拜托大家了!!!!!!!!!
- 在线等 调用值
- 对路径“XXX”的访问被拒绝?
- VS 2005中文版\网站\ASP.NET 配置 无法建立用户问题?
- 为什么我的GridView不能排序?
- 如何将查询的结果生成txt文件?
- 我的DataGrid是用自动生成列,又加了两个按钮列,为什么钮列总是出现在自动生成的列后面
- 页面导航和权限判断问题?
<!--
Sub document_onkeyup
If window.event.keyCode =13 Then
buttom2_onclick '执行Button2按下事件
End If
End Sub
-->
</SCRIPT>