ASP.NET Button UseSubmitBehaviorProperty


Button 控件Button Control

Definition and Usage

The UseSubmitBehavior property specifies whether the Button control uses the client browser's built-in submit functionality or the ASP.NET postback mechanism.

If the control uses the browser's submit functionality, the property is set to TRUE. Otherwise, it is FALSE. The default value is TRUE.

When UseSubmitBehavior is set to FALSE, ASP.NET adds a piece of client-side script to post back the form. In this case, control developers can use the GetPostBackEventReference method to return the Button's client-side postback event. The string returned by the GetPostBackEventReference method contains the text of a client-side function call, which can be inserted into a client-side event handler.

Syntax

<asp:Button UseSubmitBehavior="TRUE|FALSE" runat="server" />


Example

Example

The following example uses the ASP.NET postback mechanism:

<script runat="server">
Sub SubmitBtn(obj As Object, e As EventArgs)
  lblMsg.Text = "Submitted using the ASP.NET postback mechanism."
End Sub
</script>

<form runat="server">
Click the button:
<asp:button id="Button1" runat="server"
Text="Submit" onclick="SubmitBtn"
UseSubmitBehavior="FALSE" /><br />

<asp:label id="lblMsg" runat="server"/>
</form>

Demo Example »


Button 控件Button Control Other Extensions