Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

Panel.DefaultButton Property

Gets or sets the identifier for the default button that is contained in the Panel control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
[ThemeableAttribute(false)]
public virtual string DefaultButton { get; set; }
<asp:Panel DefaultButton="String" />

Property Value

Type: System.String
A string value corresponding to the ID for a button control contained in the Panel. The default is an empty string, indicating that the Panel does not have a default button.

Use the DefaultButton property to indicate which button gets clicked when the Panel control has focus and the user presses the ENTER key. The DefaultButton can be set to the identifier for a Button control or any control that implements the IButtonControl interface except a LinkButton control.

If the DefaultButton is set to a control that does not implement the IButtonControl interface, or to a control that is not contained in the Panel control, the Panel control throws an exception while rendering.

Setting the DefaultButton property is not supported for the following scenarios:

  • Setting focus outside of the input controls in the panel and then pressing the ENTER key. The default post back action is not guaranteed to trigger.

  • Pressing the ENTER key with focus inside a multi-line textbox. In a multi-line textbox, pressing the ENTER key should create a new line in the textbox which is the expected behavior. In browsers where the pressing the ENTER key inside a multi-line textbox triggers a post back but you want the ENTER key to create a new line instead you can attach a JavaScript function to the input control. The script should capture the ENTER key and stop the post back. For example, you can use the Attributes property collection to add client script for the onKeyPress event.

  • Referencing a default button that is a LinkButton control. Only Button and ImageButton controls are supported.

  • Changing the DefaultButton programmatically during an asynchronous post back when the Panel control is not inside of an UpdatePanel control. Asynchronous post backs can be enabled on a page by adding one or more UpdatePanel controls to the page. UpdatePanel controls can be used to update selected regions of a page instead of updating the whole page with a postback. For more information, see UpdatePanel Control Overview and Partial-Page Rendering Overview.

  • Setting this property by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins Overview.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.