Rediger

Del via


Panel.DefaultButton Property

Definition

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

public:
 virtual property System::String ^ DefaultButton { System::String ^ get(); void set(System::String ^ value); };
[System.Web.UI.Themeable(false)]
public virtual string DefaultButton { get; set; }
[<System.Web.UI.Themeable(false)>]
member this.DefaultButton : string with get, set
Public Overridable Property DefaultButton As String

Property Value

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.

Attributes

Remarks

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.

Applies to

See also