Skip to main content

Cloud

Buttons in the SharePoint Form

I was recently having an IM discussion with a colleague that reminded me of something I discovered a while back. It’s pretty simple, but I thought I’d post it here in case it helps anyone.
In a custom ASPX page in SharePoint, you can get the nifty Cancel button to show up (and actually be functional!) without writing any code.
Assuming you have a Save button that executes custom code, in your ASPX file:
<wssuc:ButtonSection runat="server">
<Template_Buttons>
<asp:PlaceHolder ID="PlaceHolder1" runat="server">
<asp:Button runat="server" class="ms-ButtonHeightWidth2" OnClick="BtnSave_Click" Text="Save" id="btnSave" />
</asp:PlaceHolder>
</Template_Buttons>
</wssuc:ButtonSection>
This will automatically include a Cancel button whose behavior is to redirect to the URL defined in the "Source" QueryString parameter.
Nice!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.