Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

UseSubmitBehavior property of the Button control - Part 39

Suggested Videos
Part 36 - Wizard control in
Part 37 - Wizard control properties
Part 38 - Wizard control events

In this video we will discuss about the UseSubmitBehavior property of the Button control. Let us understand the use of this property with an example. 

Design a webform with a TextBox, Label and 2 Button controls as shown in the image below.

For your convinience, I have included the HTML of the aspx page.
<div style="font-family: Arial">
    <strong>Name : </strong>
    <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
    <br />
    <br />
    <asp:Button ID="btnClear" runat="server" onclick="btnClear_Click" Text="Clear"/>
    <asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click" Text="Submit" />
    <br />
    <br />
    <asp:Label ID="lblMessage" runat="server" Font-Bold="True" ForeColor="#009933"></asp:Label>

Dobule click the Clear and Submit buttons, to generate the event handlers, and paste the following code in the code behind page.
protected void btnSubmit_Click(object sender, EventArgs e)
    lblMessage.Text = "You enetered: " + txtName.Text;

protected void btnClear_Click(object sender, EventArgs e)
    txtName.Text = "";

Now, run the web application project. Enter a name in the textbox and hit the enter key on the keyboard. Notice that the cancel button has the submit behaviour.

In the HTML of the aspx page, set UseSubmitBehavior="false" for the clear button.
<asp:Button ID="btnClear" UseSubmitBehavior="false" runat="server" 
onclick="btnClear_Click" Text="Clear"/>

Now, run the web application project again. Enter a name in the textbox and hit the enter key on the keyboard. Notice that the submit button has the submit behaviour, as expected.

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

This property is TRUE by default. When set to FALSE, ASP.NET adds a client-side script to post the form. To view the client side script added by the ASP.NET, right click on the broswer and view source.


  1. hi Sir your content presentation is really great.

    God bless U Sir...
    U really Like God for .Net learners...

  2. Can you please tell me in which instance would one want to "Use Submit Behavior" if the button performs the same steps?

  3. Thanks a lot sir. You are a great teacher i have ever seen in my life after my education.


It would be great if you can help share these free resources