Showing posts with label sharepoint 2010. Show all posts
Showing posts with label sharepoint 2010. Show all posts

Thursday, October 18, 2012

Code Blocks are not allowed in this file - Performance Point part 2

As discussed in the previous post how we can fix the Code block error for performance Point, now lets find the reason why the error occurs on the PPSample.aspx and how we can eliminate it at the time of writing the Feature for Masterpage.

The main reason for this error is the the page is updated with the property "customized" this can be checked by the file property "CustomizedPageStatus" in the document library.


following is the code to check if the file is customized/unghosted.

void WriteCustomizedAndNone(object sender, EventArgs e)
        {
            string myResult = '';
            string myListName = txt1.Text;
            SPList myList = SPContext.Current.Web.Site.RootWeb.Lists[myListName];
            if (!Directory.Exists('C:\\Unghosted Files\\'))
            {
                Directory.CreateDirectory('C:\\Unghosted Files\\');
            }
            myResult += 'Status of items<br><br>';
            myResult += '<table style='border:solid 1px gray;'>';
            myResult += '<tr>' + '<td>' + 'Name' + '</td>' + '<td>' + 'Setup Path' + '</td>' + '<td>' + 'is customized' + '</td>' + '</tr>';
            foreach (SPListItem anItem in myList.Items)
            {
                myResult += '<tr>' + '<td >' + anItem.Name + '</td>' + '<td >' + anItem.File.Properties['vti_setuppath'] + '</td>'  + '<td>' + anItem.File.CustomizedPageStatus + '</td>' + '</tr>';
                if (anItem.File.CustomizedPageStatus.ToString() != 'Uncustomized')
                {
                    byte[] myBytes = anItem.File.OpenBinary();
                    System.IO.File.WriteAllBytes('c:\\Unghosted Files\\' + anItem.File.Name, myBytes);
                }
            }
            myResult += '</table>';
            result.Text = myResult;
        }/*Thanks to my friend Siva for this code*/


Note: The page gets updated with the property with Customized if there is any update happens on the page after/during the feature activation, make sure there is no changes happening during the feature activation. 

Any change in the master page will result in UnGhosting which will update the file property to "Customized" and will result in the issue with Performance point "Code Blocks are not allowed in this file".




Wednesday, October 3, 2012

Code Blocks are not allowed in this file - Performance Point



After the customization of the master page in SharePoint 2010, we sometimes get the following error
"Code Blocks are not allowed in this file"

There are two solution for this
1. Add the Page Parser Path in web.config
<PageParserPaths>
       <PageParserPath VirtualPath="/BICenter/Pages/ppssample.aspx" CompilationMode="Always" AllowServerSideScript="true" />
     </PageParserPaths>

2. Modify the PerformancePoint site template by updating the /BICenter/Pages/ppssample.aspx

Replace the following
var siteCollection = "<%=SPHttpUtility.UrlPathEncode(siteCol.Value,false,true)%>";
var siteLocation = "<%=SPHttpUtility.UrlPathEncode(site.Value,false,true)%>";

with
var siteCollection = "/";
var siteLocation = "/BICenter/";

Wednesday, September 5, 2012

Dialog box Styling in SharePoint 2010

SharePoint 2010 has two important classes to control the dialog display
.s4-notdlg
.ms-dialog


s4-notdlg
Apply the class to any div which is not required to disply

ms-dialog
This class is added to the tag of dialog, so we can modify the css of any class in the dialog.
e.g.
.ms-dialog .ms-cui-topBar2
{
   height:0px;
}

Wednesday, June 22, 2011

List Throttling

List Throttling is a new feature in SharePoint 2010, it allows us to set the limit of how many rows of data can be retrieved from a list at a time. By default the list throttles to 5000 items. Let’s consider we have a list with 50000 entries and a user comes and creates a view with all the entries, then the SharePoint will return either error or the first set of results up to the number put in the list throttle.
The throttle can be set on the lookups in a list, and we can limit the lookup columns. If we have too many lookups the performance will suffer. As we limit maximum throttle for the user, we can override the same on the Object Model if we have the sufficient privilege.

using (SPSite site = new SPSite("http://mysite"))
{
using (SPWeb web = site.RootWeb)
{
try
{
SPList list = web.Lists["Shared Documents"];

SPQuery qry = new SPQuery();
qry.QueryThrottleMode = SPQueryThrottleOption.Override;

SPListItemCollection coll = list.GetItems(qry);
}
catch(SPQueryThrottledException)
{
// Throttle exception
}
}
}

Wednesday, January 6, 2010

Adding the New Form of list on the View

1.Open the view in the designer.
2.Switch to Designer Mode.
3.Click on Insert.
4.On the Ribbon select the New Form dropdown and select the List.
5.All the Mandatory fields will be available
6.To add ther field switch to the Design Mode and add the two tags for the field
7.Copy the tags generated for the Mandatory field and update the field name and the ID
8.Save the form

Just refresh the page after entering the values.

Change the column name for specific View

While creating the new view in the sharepoint list library select "Custom View in SharePoint Designer". The site will open in the designer. Provide the view name and double click on the new view created in the designer, get into the designer view and update the column Name. We can append the static values after the content also like for the currency we can append $ before the field so that in the view when someone opens it will display the values prefixed with $.

Monday, January 4, 2010

Inline add edit in Sharepoint 2010

Inline Add/Edit
Till now to add/edit an item in the list we used to go to the edit window and then add/update the data, but in the 2010 we can directly do by enabling the Inline Editing for adding new and by enabling the Tabular view individual items ca be edited.

Add an item


Edit an item