摘要:網頁顯示時,游標停駐在特定控制項 + 按下Enter鍵等於按下特定按鈕
讓網頁顯示時,游標停駐在帳號的地方!
按下Enter鍵,是按下送出鈕!
aspx
01 <form id="form1" runat="server" defaultbutton="Button1" defaultfocus="TextBox1">
02 <div>
03
04 帳號:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
05 <br />
06 密碼:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
07 <br />
08 <asp:Button ID="Button1" runat="server" Text="送出" onclick="Button1_Click" />
09 <asp:Button ID="Button2" runat="server" Text="重填" />
10
11 </div>
12 </form>
02 <div>
03
04 帳號:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
05 <br />
06 密碼:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
07 <br />
08 <asp:Button ID="Button1" runat="server" Text="送出" onclick="Button1_Click" />
09 <asp:Button ID="Button2" runat="server" Text="重填" />
10
11 </div>
12 </form>
重點只在第一行,form屬性中的defaultbutton、defaultfocus二個屬性值預先設定好即可!