ASP.NET UseSubmitBehavior Property
Definition and Usage
The UseSubmitBehavior property specifies whether the button control uses the built-in submission feature of the client browser or the ASP.NET postback mechanism.
This property is set to TRUE if the control uses the browser's submission mechanism. Otherwise, it is FALSE. The default value is TRUE.
When set to FALSE, ASP.NET will add a client script to post back the form.
When the UseSubmitBehavior property is set to false, control developers can use the GetPostBackEventReference method to return the client postback event of the Button. The GetPostBackEventReference method returns a string containing the text of the client function call, which can be inserted into the client event handler.
Syntax
<asp:Button UseSubmitBehavior="TRUE|FALSE" runat="server" />
Example
The following example uses ASP.NET's 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>
Example
- Using ASP.NET's postback mechanism on button controls