国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

ASP.NET 2.0 - Enter Key - Default Submit Button

2024-07-10 13:09:47
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

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

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

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

下面的實(shí)例代碼中有一個(gè)表單和4個(gè)面板,報(bào)單和面板中都有按鈕。情各位注意:在文本框中回車后會(huì)觸發(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);
}

原文:http://forums.asp.net/thread/1270048.aspx


原文:http://forums.asp.net/thread/1270048.aspx
 代碼下載

實(shí)在不知道"entry key"應(yīng)該如何翻譯,請(qǐng)各位指教。
謝謝


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 安乡县| 太谷县| 武山县| 鹤峰县| 承德市| 互助| 西乌| 全州县| 延吉市| 盐津县| 云和县| 信宜市| 阜平县| 金川县| 商都县| 蓝田县| 阿勒泰市| 韶关市| 高陵县| 望城县| 天祝| 德惠市| 阜新| 无棣县| 威海市| 榆树市| 年辖:市辖区| 竹溪县| 邳州市| 依兰县| 临颍县| 海盐县| 六安市| 平塘县| 湘阴县| 灵川县| 松溪县| 安平县| 枣阳市| 富顺县| 正定县|