Skip to main content

Cancel Button in MOSS ASPX , ASCX forms

Hi All,

One time i came across to a very good thing that we can have default cancel button that with without writing a code you can redirect to any source. (if not provided, default source)

This button is functional. By functional means it will handle redirection automatically.

Let's say, you would like to have a button Cancel (Sharepoint standard) and want that button to behave in same fashion as standard sharepoint cancel button does, then go for the below code :

<wssuc:ButtonSection runat="server">

<Template_Buttons>

<asp:PlaceHolder ID="PlaceHolder1" runat="server">

</asp:PlaceHolder>

</Template_Buttons>

</wssuc:ButtonSection>


No code on cancel button. it redirects automatically to source.

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


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.


That's it. your job is done.

Comments

Popular posts from this blog

How to get SPUser or SPGroup from Person or Group field

You have person or group field in SharePoint list and you want to programmatically get the user or person. The below code to gets SPUser from User or Group field in the list when multiple choice and Groups are not allowed in the field: //get SPUser SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users"); SPFieldUserValue userFieldValue = (SPFieldUserValue)userField.GetFieldValue(item["Users"].ToString()); SPUser user = userFieldValue.User; This part of code would help you to get SPUser when multiple choice is allowed and groups are not allowed: //Multiple choices are allowed SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users"); SPFieldUserValueCollection userFieldValueCollection = (SPFieldUserValueCollection)userField.GetFieldValue(item["Users"].ToString()); foreach (SPFieldUserValue userFieldValue in userFieldValueCollection) {     Console.WriteLine("     " + userFieldValue.User.LoginName); } And when group

SharePoint publishing page scheduling

In SharePoint 2010 publishing enabled team site collection is not showing schedule button in publish ribbon. Solution: Here is how to enable it  though the UI: Locate the SharePoint Server Web site on which you want to enable content approval and item scheduling. Click  Site Actions , click  Site Settings , and then click  Modify Pages Library Settings . Under  General Settings , click  Versioning Settings . Click  Yes  next to  Content Approval , and then click  OK . Click  Manage item scheduling .   Click to enable the  Enable scheduling of items in this list  check box, and then click  OK .

Changing Content Type Hub URL

Change the Hub URL through powershell by using: Set-SPMetadataServiceApplication -Identity " " -HubURI " " For Ex: Set-SPMetadataServiceApplication -Identity "Managed Metadata Service" -HubURI "http://contenttype.Domain.Com" When you try to do this you get this rather scary message: This is SharePoint telling you that this is a major thing so be careful! Essentially all your content types that you have published out will be removed if they can, and you have to republish all of your content types out again which can cause some issue.