Friday, April 17, 2009

WPSC undefined Javascript Error

While Removing Core.JS and related files we will get WPSC Undefined Error in Share point web part pages.
If we get the error WPSC undefined as a java script use the following java script code

if(typeof(WPSC) == "undefined"){
WPSC = new Object();
WPSC.Init = function(){
//do nothing
WPSC.WebPartPage = new Object();
WPSC.WebPartPage.Parts = new Object();
WPSC.WebPartPage.Parts.Register = function()
//do nothing

Tuesday, April 7, 2009

Hide Core.CSS,Core.JS and Related Contents


If we need to remove the Core.CSS, Core.JS and related files just do the following steps

1)keep the links a) and b) in a ContentPlaceHolder named "PlaceHolderAuthendicatedLinks" and keep the ContentPlaceHolder visible=false

a)<sharepoint:csslink runat="server" />--->For Core.CSS and Related CSS files
b)<sharepoint:scriptlink language="javascript" runat="server" name="core.js" defer="true" />----->For Core.JS and Related Files

<asp:contentplaceholder id="PlaceHolderAuthendicatedLinks" runat="server" visible="false">
<sharepoint:csslink runat="server"></sharepoint:csslink>
<sharepoint:scriptlink language="javascript" runat="server" name="core.js" defer="true"></sharepoint:scriptlink>
2)if we need the Core.CSS and Core.JS files with any of a condition, just set the visible as true
3)For an example i dont want to load these files for anonymous users and i need these files for authenticated users
4)For that i did as default ContentPlaceHolder visible=false and set the visible=true in page load event using C# inline code

<script runat="server">

void Page_load(object sender, EventArgs e)
if (HttpContext.Current.Request.IsAuthenticated)
PlaceHolderAuthendicatedLinks.Visible = true;