10,000 Monkeys - Harnessing the Power of Typing Monkeys
America's 2,672,401st Most Read Blog by Kevin Marshall.
Sign in
|
Join
|
Help
in
10,000 Monkeys - Harnessing...
Clarity Employees
(Entire Site)
Home
About
RSS
Atom
Comments RSS
Recent Posts
Microsoft's PhizzPop Design Competition Finals Wrap-up
Google AJAX Language API & Office Communicator Custom Translation Tabs
From the 10K Monkey's Vault: Coding4Fun
Faux Giant Application Icon with Extended Aero Glass in WPF
Sharepoint Search from Tafiti
Tags
ASP.NET
Gadgets
Non-Microsoft Products
Server Products
Visual Studio Team System
Windows Forms
Windows Presentation Foundation (WPF)
Navigation
Home
Archives
April 2008 (1)
March 2008 (1)
February 2008 (1)
December 2007 (3)
November 2007 (1)
October 2007 (16)
April 2006 (8)
March 2006 (17)
February 2006 (8)
December 2005 (1)
Default Buttons on ASP.NET 2.0 Forms
First I want to welcome the new reader I gained from my
Coding4Fun
article. Perhaps your dog accidentaly jumped on the keyboard and clicked the link to my site or maybe you're new to the english language and you were looking for the German Coding4Fun site. Willkommen. I'm sure you'll find
a wealth of literary delights
10-15 minutes of mindless reading
here.
Anyway, how do you set the default button when you have multiple buttons on a form? My first response would be "Just build a winform app and stop trying to hack together desktop app like functionality on the web" (Note: Several explatitves were removed since this is a family friendly site) Now with ASP.NET you can set the default button on forms and panels so that if you click Enter in a text box, it'll submit with that button.
So if you have two different sets of inputs with save buttons, you can place them in a panel and set the default button for input fields in that panel. Like so:
<html>
<body>
<form runat=“server”>
<asp:panel defaultbutton=“btn2” runat=“server”>
<asp:textbox id=“Name” runat=“server”/>
<asp:button id=btn2 runat=“server”/>
</asp:panel>
<asp:panel defaultbutton=“btn3” runat=“server”>
<asp:textbox id=“Address” runat=“server”/>
<asp:button id="btn3" runat=“server”/>
</asp:panel>
</form>
</body>
</html>
Now you can fire off different events all over your form with a simple click of the Enter key!
Posted:
Mar 16 2006, 08:39 AM
by
kmarshall
| with
no comments
Filed under:
ASP.NET
Comments
No Comments
Leave a Comment
Title
(required)
Name
(required)
Your URL
(optional
)
Comments
(required)
Remember Me?