Panel.DefaultButton 屬性

定義

取得或設定 Panel 控制項中包含之預設按鈕的識別項。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

屬性值

String

字串值,對應於 ID 中所包含之按鈕控制項的 PanelA string value corresponding to the ID for a button control contained in the Panel. 預設值是空字串,表示 Panel 沒有任何預設按鈕。The default is an empty string, indicating that the Panel does not have a default button.

屬性

備註

DefaultButton 可以使用屬性來指出當 Panel 控制項有焦點且使用者按下 ENTER 鍵時,所按的按鈕。Use the DefaultButton property to indicate which button gets clicked when the Panel control has focus and the user presses the ENTER key. DefaultButton可以設定為控制項的識別碼, Button 或任何實作為 IButtonControl 控制項以外之介面的控制項 LinkButtonThe DefaultButton can be set to the identifier for a Button control or any control that implements the IButtonControl interface except a LinkButton control.

如果 DefaultButton 設定為不會執行介面的控制項 IButtonControl ,或設定為不包含在控制項中的控制項 Panel ,則在轉譯 Panel 時,控制項會擲回例外狀況。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.

DefaultButton下列案例不支援設定屬性:Setting the DefaultButton property is not supported for the following scenarios:

  • 將焦點設定在面板的輸入控制項外,然後按下 ENTER 鍵。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.

  • 在多行文字方塊內按 ENTER 鍵,並將焦點放在多行文字方塊內。Pressing the ENTER key with focus inside a multi-line textbox. 在多行文字方塊中,按 ENTER 鍵應該會在文字方塊中建立新的行,這是預期的行為。In a multi-line textbox, pressing the ENTER key should create a new line in the textbox which is the expected behavior. 在瀏覽器中,在多行文字方塊內按 ENTER 鍵會觸發回傳,但您想要讓 ENTER 鍵建立新的行,而不是您可以將 JavaScript 函式附加至輸入控制項。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. 腳本應該會捕捉 ENTER 鍵,並停止回送。The script should capture the ENTER key and stop the post back. 例如,您可以使用 Attributes 屬性集合來加入事件的用戶端腳本 onKeyPressFor example, you can use the Attributes property collection to add client script for the onKeyPress event.

  • 參考屬於控制項的預設按鈕 LinkButtonReferencing a default button that is a LinkButton control. Button ImageButton 支援和控制項。Only Button and ImageButton controls are supported.

  • DefaultButtonPanel 控制項不在控制項內時,以程式設計方式在非同步回傳期間變更 UpdatePanelChanging the DefaultButton programmatically during an asynchronous post back when the Panel control is not inside of an UpdatePanel control. 將一或多個控制項新增至頁面,即可在頁面上啟用非同步 post 支援 UpdatePanelAsynchronous post backs can be enabled on a page by adding one or more UpdatePanel controls to the page. UpdatePanel 控制項可用來更新頁面的選取區域,而不是使用回傳來更新整頁。UpdatePanel controls can be used to update selected regions of a page instead of updating the whole page with a postback. 如需詳細資訊,請參閱 UpdatePanel 控制項總覽局部頁面轉譯總覽For more information, see UpdatePanel Control Overview and Partial-Page Rendering Overview.

  • 依主題或樣式表單主題設定這個屬性。Setting this property by themes or style sheet themes. 如需詳細資訊,請參閱 ThemeableAttributeASP.NET 主題和外觀For more information, see ThemeableAttribute and ASP.NET Themes and Skins.

適用於

另請參閱