Karine Bosch’s Blog

On SharePoint

ButtonSection.ascx Control


When developing application pages, you can use this control to place a button section on the page. In this button section you can place one or more buttons that execute the actions to take.

buttonsection4 

  To include a ButtonSection control on an application page you have to use the following syntax:

<wssuc:ButtonSection runat="server" ShowStandardCancelButton="true">
    <template_buttons>
       <asp:PlaceHolder runat="server">               
           <asp:Button id="SubmitButton" UseSubmitBehavior="false" runat="server" class="ms-ButtonHeightWidth" 
                       Text="OK" OnClick="SubmitButton_Click" />
       </asp:PlaceHolder>
    </template_buttons>
</wssuc:ButtonSection>

Add also a directive at the top of the page:

<%@ Register TagPrefix="wssuc" TagName="ButtonSection" Src="/_controltemplates/ButtonSection.ascx" %>

Code for the OnClick event of the individual buttons needs to be written within a <script runat=”server” language=”C#”> tag on the application page or in the code behind class from which the application page inherits:

 protected Button SubmitButton;        
 public void SubmitButton_Click(object sender, System.EventArgs e)
 {
     // TODO: must save the changes proposed on the page
 }

There are also a number of attributes you can set on the ButtonSection control:

  •  ShowStandardCancelButton: if you set this property to true, a Cancel button is automatically added to the ButtonSection control. This cancel button will redirect the user to the previous page in the browser history.
  • ShowSectionLine: set this property to false if you don’t want a section line to be added above the buttons. The default value is true.
  • BottomSpacing: in case of long pages it is possible you want to add a button section at the top of the page and one at the bottom of the page. If you put a button section at the top of the page, you can set this property to a value higher than zero to add extra blank spacing between the button section and the controls that follow.
  • SmallSectionLine: if you set this boolean value to true, the section line will be 1px high; if set to false, the section line will be 2px high. The default is false.

10 Comments »

  1. Thanks for the post. This is very usefule.
    If I use the default cancel button in my page, the cancel button click taks me to the site’s home page instead of the previous page in the broswer’s history. how do I fix this?

    <asp:Button UseSubmitBehavior="false" runat="server" OnClick="BtnSave_Click" Text="” id=”BtnSave” accesskey=””/>

    Comment by Saraswathy | October 7, 2009 | Reply

    • Hi saraswathy,

      use history.back javascript code in button click event.

      Comment by naveen | November 25, 2009 | Reply

  2. Thank you! This Post helped me alot! Its much better than the MSDN Article.

    Comment by Yavuz B. | June 6, 2010 | Reply

  3. This article is good, but I don’t understand the UseSubmitBehaviour=”false”

    Can you tell me why?

    Comment by Peter | July 26, 2011 | Reply

  4. Can you please explain, how to use the save button in share point or give me share point control button which will work as same as asp button. I want use only share point controls

    Comment by shiva | April 6, 2013 | Reply

  5. Shiva, it is explained above: place an ASP.NET button within a button section and give it the name Save. In the code behind you add to add an event handler for your ASP.NET button.
    On what exactly do you need more details?

    Comment by Karine Bosch | April 8, 2013 | Reply

    • How to use save button in sharepoint as same as button in asp.net

      Comment by shiva | April 12, 2013 | Reply

  6. Being a newbie I am trying out some of these controls, with the help of this I was successful in simplifying three cases of web presentation amongst which one was to submit once using button control.

    Comment by Hayden Hopper | June 13, 2013 | Reply

  7. Thx, this was EXTREMELY helpful!

    Greetings from Switzerland

    Comment by Dave the Rave | September 5, 2013 | Reply

    • Thanks Dave.

      Comment by Karine Bosch | September 5, 2013 | Reply


Leave a comment