濮阳杆衣贸易有限公司

主頁 > 知識庫 > ASP.NET2.0使用Enter Key作為默認提交問題分析(附源碼)

ASP.NET2.0使用Enter Key作為默認提交問題分析(附源碼)

熱門標簽:400電話辦理哪家性價比高 地圖標注專業(yè)團隊 遂寧市地圖標注app 天心智能電銷機器人 地圖定位圖標標注 塔城代理外呼系統(tǒng) 代理接電話機器人如何取消 濮陽外呼電銷系統(tǒng)怎么樣 地圖標注的公司有哪些

本文實例分析了ASP.NET2.0使用Enter Key作為默認提交的方法。分享給大家供大家參考,具體如下:

網(wǎng)頁開發(fā)中最煩人的事情之一就是為表單處理"Enter key" ,"Enter key"已經(jīng)成為用戶提交表單的偏好。雖然我們?yōu)橛脩籼峁┝颂峤话粹o,但是最簡單也是最直接的方式仍然是:輸入文字,然后回車完成提交

ASP.NET 2.0中為此提供了很好的解決方法。只需要將"defaultbutton"屬性指定到想要引發(fā)事件的按鈕控件的ID上就可以了。

在表單級別和面板級別(asp:panel> 標記)均可以指定"defaultbutton"。當表單和面板中同時指定了defaultbutton,則如果在面板中觸發(fā)了"Enter key",則執(zhí)行面板中的

下面的實例代碼中有一個表單和4個面板,報單和面板中都有按鈕。情各位注意:在文本框中回車后會觸發(fā)哪些按鈕的事件

form id="form1" runat="server" defaultbutton="btn1">
div>
asp:TextBox ID="txt" runat="server">/asp:TextBox>
asp:Button ID="Button5" runat="server" Text="Cancel" OnClick="Button5_Click" />
asp:Button ID="btn1" runat="server" Text="Submit" OnClick="btn1_Click" />
asp:Panel ID="pnl1" runat="server" defaultbutton="Button1">
asp:TextBox ID="TextBox1" runat="server">/asp:TextBox>
asp:TextBox ID="TextBox2" runat="server">/asp:TextBox>
asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button1_Click" />
/asp:Panel>
asp:Panel ID="Panel1" runat="server" defaultbutton="Button2">
asp:TextBox ID="TextBox3" runat="server">/asp:TextBox>
asp:TextBox ID="TextBox4" runat="server">/asp:TextBox>
asp:Button ID="Button2" runat="server" Text="Button2" OnClick="Button2_Click" />
/asp:Panel>
asp:Panel ID="Panel2" runat="server" defaultbutton="Button3">
asp:TextBox ID="TextBox5" runat="server">/asp:TextBox>
asp:TextBox ID="TextBox6" runat="server">/asp:TextBox>
asp:Button ID="Button3" runat="server" Text="Button3" OnClick="Button3_Click" />
/asp:Panel>
asp:Panel ID="Panel3" runat="server" defaultbutton="Button4">
asp:TextBox ID="TextBox7" runat="server">/asp:TextBox>
asp:TextBox ID="TextBox8" runat="server">/asp:TextBox>
asp:Button ID="Button4" runat="server" Text="Button4" OnClick="Button4_Click" />
/asp:Panel>
/div>
/form>
//The corresponding, sample events for the button clicks are
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(Button1.Text);
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write(Button2.Text);
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Write(Button3.Text);
}
protected void Button4_Click(object sender, EventArgs e)
{
Response.Write(Button4.Text);
}
protected void btn1_Click(object sender, EventArgs e)
{
Response.Write(btn1.Text);
}
protected void Button5_Click(object sender, EventArgs e)
{
Response.Write(Button5.Text);
}

完整實例代碼代碼點擊此處本站下載。

希望本文所述對大家asp.net程序設(shè)計有所幫助。

您可能感興趣的文章:
  • ASP.NET基于Ajax的Enter鍵提交問題分析
  • asp.net textbox javascript實現(xiàn)enter與ctrl+enter互換 文本框發(fā)送消息與換行(類似于QQ)
  • asp.net(c#)Enterprise Library 3.0 下載
  • ASP.Net 請求響應(yīng)流程簡述
  • asp.net實現(xiàn)取消頁面表單內(nèi)文本輸入框Enter響應(yīng)的方法

標簽:吉林 麗江 汕頭 宜春 河南 本溪 婁底 重慶

巨人網(wǎng)絡(luò)通訊聲明:本文標題《ASP.NET2.0使用Enter Key作為默認提交問題分析(附源碼)》,本文關(guān)鍵詞  ASP.NET2.0,使用,Enter,Key,作為,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP.NET2.0使用Enter Key作為默認提交問題分析(附源碼)》相關(guān)的同類信息!
  • 本頁收集關(guān)于ASP.NET2.0使用Enter Key作為默認提交問題分析(附源碼)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    军事| 崇仁县| 房山区| 阿鲁科尔沁旗| 安仁县| 隆回县| 三台县| 蓬溪县| 邵东县| 鸡西市| 罗甸县| 乳山市| 隆德县| 许昌县| 临西县| 潜山县| 惠来县| 八宿县| 阿坝| 云和县| 大足县| 错那县| 门源| 同德县| 沧源| 固原市| 沐川县| 黔江区| 舟曲县| 巴中市| 长春市| 阿合奇县| 双江| 余庆县| 松潘县| 成安县| 烟台市| 镇远县| 新疆| 广安市| 孟连|