Export (0) Print
Expand All

Button.UseSubmitBehavior Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets a value indicating whether the Button control uses the client browser's submit mechanism or the ASP.NET postback mechanism.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public virtual bool UseSubmitBehavior { get; set; }
/** @property */
public boolean get_UseSubmitBehavior ()

/** @property */
public void set_UseSubmitBehavior (boolean value)

public function get UseSubmitBehavior () : boolean

public function set UseSubmitBehavior (value : boolean)

Property Value

true if the control uses the client browser's submit mechanism; otherwise, false. The default is true.

Use the UseSubmitBehavior property to specify whether a Button control uses the client browser's submit mechanism or the ASP.NET postback mechanism. By default the value of this property is true, causing the Button control to use the browser's submit mechanism. If you specify false, the ASP.NET page framework adds client-side script to the page to post the form to the server.

When the UseSubmitBehavior property is false, control developers can use the GetPostBackEventReference method to return the client postback event for the Button. The string returned by the GetPostBackEventReference method contains the text of the client-side function call and can be inserted into a client-side event handler.

This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins Overview.

The following code example demonstrates how to use the UseSubmitBehavior property to specify the submit mechanism that a Button control uses when it posts back to the server. The UseSubmitBehavior property is set to false, causing the button to use the ASP.NET postback mechanism. If you view the source code for the rendered page using your browser's View Source command, you will see that client-side script has been added by the ASP.NET page framework to post the form to the server.

<%@ page language="C#" %>

<script runat="server">
  void SubmitBtn_Click(object sender, EventArgs e)
    Message.Text = "Hello World!";    


<head id="Head1" runat="server">
  <title>Button.UseSubmitBehavior Example</title>
  <form id="Form1" runat="server">

    <h3>Button.UseSubmitBehavior Example</h3> 

    Click the Submit button.
    <br /><br /> 

    <!--The value of the UseSubmitBehavior property
    is false. Therefore the button uses the ASP.NET 
    postback mechanism.-->
    <asp:button id="Button1"

    <br /><br /> 

    <asp:label id="Message" 


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions

© 2015 Microsoft