Skip Ribbon Commands
Skip to main content

Fereshteh Shafaghi

:

Quick Launch

Home
May 23
InfoPath: How to receive data from specific view of a SharePoint List
In infopath you need to create a DataConnections that receive data from XML document and in browse section you have to get the xml from the example url:
April 05
SharePoint edit listitem access denied

After installing sp2 there was a weird problem.User was able to create new item but after editing he was denied to access the listitem. after googling I found a code at here to fix it.

private void btnapply_Click(object sender, EventArgs e){

string RenderXMLPattenAttribute = "RenderXMLUsingPattern";

string weburl = txtwebUrl.Text;

string listName = txtListName.Text;

SPSite site = new SPSite(weburl);

SPWeb web = site.OpenWeb();

SPList list = web.Lists[listName];

SPField f = list.Fields.GetFieldByInternalName("PermMask");

string s = f.SchemaXml;

Console.WriteLine("schemaXml before: " + s);

XmlDocument xd = new XmlDocument();

xd.LoadXml(s);

XmlElement xe = xd.DocumentElement;

if (xe.Attributes[RenderXMLPattenAttribute] == null)

{

XmlAttribute attr = xd.CreateAttribute(RenderXMLPattenAttribute);

attr.Value = "TRUE";

xe.Attributes.Append(attr);

}

string strXml = xe.OuterXml;

Console.WriteLine("schemaXml after: " + strXml);

f.SchemaXml = strXml;

}

March 04
Create other site templates under publishing site
Publishing site with workflows be default allow us to create the same site template under it. So if there is a need to create site with different template we should go to /_layouts/Areatemplatesettings.aspx and select other site templates or remove the restriction.
February 28
Deploying Microsoft Chart into SharePoint 2007

Microsoft Chart Controls can be downloaded from here.

Required dlls in GAC:

·         System.Web.DataVisualization.Design.dll  

·         System.Web.DataVisualization.dll

·         System.Windows.Forms.DataVisualization.Design.dll

·         System.Windows.Forms.DataVisualization.dll

 

Web.config

 

1)      Add the dlls as Safe

<SafeControl Assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"  Namespace="System.Web.UI.DataVisualization.Charting" TypeName="*" Safe="True" AllowRemoteDesigner="True"/>

2)      Add this code in <httphandlers>

<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />

3)      Add this code in <appsettings>

 <add key="ChartImageHandler" value="storage=memory;timeout=20;URL=/_layouts/Images/MicrosoftChartControls/" />

 

Sample code for the WebPart :

protected override void CreateChildControls()

{

    base.CreateChildControls();

    Chart testchart = new Chart();

    testchart.Width = Unit.Pixel(600);

    ChartArea chartarea = new ChartArea();

    chartarea.Name = "Test";

    testchart.ChartAreas.Add(chartarea);

 

    Series testseries = new Series();

    DataPoint dp1 = new DataPoint();

    dp1.AxisLabel = "Celtics";

    dp1.SetValueY(17);

 

    DataPoint dp2 = new DataPoint();

    dp2.AxisLabel = "Bulls";

    dp2.SetValueY(6);

 

    DataPoint dp3 = new DataPoint();

    dp3.AxisLabel = "Pistons";

    dp3.SetValueY(20);

           

    testseries.Points.Add(dp1);

    testseries.Points.Add(dp2);

    testseries.Points.Add(dp3);

    testchart.Series.Add(testseries);

    this.Controls.Add(testchart);          

 }

January 24
Best Practices for SharePoint development
 
  1. dispose SPSite and SPWeb in Finally block
  2. Use RunWithElevatedPrivileges in order to aviod permission errors
  3. Try writing your errors into SharePoint error logs using SPDiagnosticServices
  4. Use SPQuery instead of foreach
  5. solutions (WSP = SharePoint Solution Package) are so important
  6. Do not instantiate SPSite and SPWeb inside an Event Receiver
 
 
January 10
Passed 573
I have passed Microsoft SharePoint 2010, Application Development at 9th Jan 2011.
January 05
Developer Dashboard in SharePoint 2010
Developer dashboard is a great feature in SharePoint 2010 which helps developers to find the problem in code that cause memory leak. For further investigation you can refer to here.
 
To set it programmatically you should follow these steps:
 
SpWebservice cs = SPWebService.ContentService;
cs.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.On;
cs.DeveloperDashboardSettings.Update();
December 09
CQWP: Use Page Url in xsl
In my CQWP I needed current page url, to go back to the source page.
To have pageurl you need to do following steps:
1) Adding related namespace to the xsl file:
<xsl:stylesheet
    version="1.0"
    exclude-result-prefixes="x xsl cmswrt cbq"
    xmlns:x="http://www.w3.org/2001/XMLSchema"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:cmswrt="http://schemas.microsoft.com/WebPart/v3/Publishing/runtime"
    xmlns:cbq="urn:schemas-microsoft-com:ContentByQueryWebPart"
   
>>> xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v3/DataView/runtime">

2) Add the parameter:
    <xsl:param name="PageUrl" />

3) In your template you can have:
 <a href="../imagedetail.aspx?id={@ID}&amp;Source={$PageUrl}">
 
December 07
SharePoint Designer says I have a file checked out, but I don't
There is a post  here which saved my time. Many thanks to Tom Puleo.
 
For me the issue resolved when I tried to open the page!
December 07
Output cache vary by custom parameter
In our company we had a wired issue! Our page did not send a request to server on changing url!! This issue also happened for changing cookies!
 
After googling I noticed that we can customise output caching based on our custom parameter. you can also refer msdn for further investigations.
 
The steps to change caching parameters are:
 
1) Create class with this code:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Text;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using Microsoft.SharePoint.Publishing;

using Microsoft.SharePoint.ApplicationRuntime;

using Microsoft.SharePoint;

namespace OneStop.CCD.Providers

{

public class CacheHttpApplication : SPHttpApplication, IVaryByCustomHandler

{

internal const string MyVaryByString1 = "SupportsCSS";

internal const string MyVaryByString2 = "SiteAdmin";

public override void Init()

{

base.Init();

this.RegisterGetVaryByCustomStringHandler((Microsoft.SharePoint.ApplicationRuntime.IVaryByCustomHandler)this);

}

public string GetVaryByCustomString(HttpApplication app, HttpContext context, string custom)

{

string[] strings = custom.Split(';');

string cacheKey = string.Empty;

foreach (string arg in strings)

{

if (arg.ToLower().Equals("rawurl"))

{

return context.Request.RawUrl;

}

if (arg.ToLower() == "cookie")

{

HttpCookie countryCookie = context.Request.Cookies

[System.Web.Configuration.WebConfigurationManager.AppSettings["CookieCountry"]];

HttpCookie languageCookie = context.Request.Cookies

[System.Web.Configuration.WebConfigurationManager.AppSettings["CookieLanguage"]];

if (countryCookie != null && languageCookie != null)

{

cacheKey += countryCookie.Value + languageCookie.Value;

}

}

}

return cacheKey;

}

}

}

2) Copy related assembly in both GAC and related site's bin

3)Change global.asax to read your customised dll

<%@ Assembly Name="Microsoft.SharePoint"%>
<%@ Assembly Name="OneStop.CCD.Providers"%>
<%@ Import Namespace="OneStop.CCD.Providers" %>
<%@ Application Language="C#" Inherits="OneStop.CCD.Providers.CacheHttpApplication" %>
 
4) In destination site go to Site Settings> Modify all site settings> Site collection cache profiles> add your custom parameter to "Vary by Custom Parameter".
1 - 10Next