Monday, August 22, 2011

Failed to instantiate file from module The specified list does not exist.

Hi
In case anyone else has this problem try to change

Type="GhostableInLibrary" to

Type="Ghostable"

worked for me


Here I am trying to deploy master page my elements.xml file is like below after modification










Thanks to the author @

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/27ac36ca-3d3a-47eb-9fc6-ee1b1846b8a3/


http://vspug.com/george/2008/02/05/failed-to-instantiate-file-quot-file-ext-quot-from-module-quot-modules-quot-the-specified-list-does-not-exist/

sharepoint 2010 Datetime field default value + add days

You can set datetime default field value not only Today, but you can have your own calculated value.

select any datetime field--->for default value select "Calcualted Value"

then you can give =TODAY()+ 10


for one year---->its =TODAY()+365

Thursday, August 18, 2011

sharepoint 2010 + item event receivers + session

I've been googling for last couple of hours for the correct post.

"How to use sessions in sharepoint item event handlers"

finally I could find the correct link(see below). Thanks to the author.

In a nut shull, it is available in synchronous events (adding, updating).
Not available in Async events (Added, Updated).

define a variable in receiver class, assign the HttpContext.Current in default constructor.


HttpContext hContext = null;

public MyCustomEventHandler() : base()
{
hContext = HttpContext.Current;
}


public override void ItemAdding(SPItemEventProperties properties)
{
hContext.Response.Redirect(“http://microsoft.com”)
}



http://blogs.msdn.com/b/sowmyancs/archive/2008/03/25/can-we-get-the-httpcontext-in-custom-event-handlers-in-sharepoint.aspx

Friday, March 18, 2011

sharepoint list data to excel, programatically

thanks to the author,

http://avinashkt.blogspot.com/2009/05/programmatically-export-records-from.html

here is the trick

string spListName = "CartDetails";
SPList oList = SPContext.Current.Web.Lists[spListName];
string listGUID = oList.ID.ToString().ToUpper().Replace("-", "\u00252D");
string viewGUID = oList.DefaultView.ID.ToString().ToUpper().Replace("-", "\u00252D");
strCommand = "javascript:EnsureSSImporter();" +
"javaScript:ExportList('\u002f_vti_bin\u002fowssvr.dll?CS=65001\u0026"
+ "Using=_layouts\u002fquery.iqy\u0026" + "List=\u00257B"
+ listGUID + "\u00257D\u0026" + "View=\u00257B" + viewGUID
+ "\u00257D\u0026" + "RootFolder=\u00252FLists\u00252F"
+ spListName.Replace("_", "\u00255F") + "\u0026" + "CacheControl=1')";

btnExportToExcel.Attributes.Add("onclick", strCommand+"; return false;");

Thursday, March 10, 2011

SharePoint SPMetal + CreatedBy, Created

string _CreatedBy;
[Microsoft.SharePoint.Linq.ColumnAttribute(Name = "Author", Storage = "_CreatedBy", ReadOnly = true, FieldType = "User", IsLookupValue = true)]
public string CreatedBy { get { return this._CreatedBy; } set { if ((value != this._CreatedBy)) { this.OnPropertyChanging("CreatedBy", this._CreatedBy); this._CreatedBy = value; this.OnPropertyChanged("CreatedBy"); } } }


DateTime _Created;
[Microsoft.SharePoint.Linq.ColumnAttribute(Name = "Created", Storage = "_Created", ReadOnly = true, FieldType = "DateTime", IsLookupValue = false)]
public DateTime Created { get { return this._Created; } set { if ((value != this._Created)) { this.OnPropertyChanging("Created", this._Created); this._Created = value; this.OnPropertyChanged("Created"); } } }


1 Name="Editor" Member="ModifiedBy"
2 Name="Author" Member="CreatedBy"
3 Name="Created"
4 Name="Modified"

Monday, March 7, 2011

javascript convert number to currency . ex:- 1234.56, 1234.00

Thanks to the author, I missed the original link

function CurrencyFormatted(amount) {
var i = parseFloat(amount);
if (isNaN(i)) { i = 0.00; }
var minus = '';
if (i < 0) { minus = '-'; }
i = Math.abs(i);
i = parseInt((i + .005) * 100);
i = i / 100;
s = new String(i);
if (s.indexOf('.') < 0) { s += '.00'; }
if (s.indexOf('.') == (s.length - 2)) { s += '0'; }
s = minus + s;
return s;
}

asp.net gridview, column total in footer using java script

Thanks to the author @ http://forums.asp.net/t/1168003.aspx
--------------------
In my grid I have one label in template field which stores item price, I want to show the total of items on label in footer.

function RetrievePackageDetailInputs() {
try {
var totVal = 0;
rows = document.getElementById('<%= gvCartDetails.ClientID %>').getElementsByTagName("TR");
for (var j = 1; j < rows.length - 1; j++) { cells = rows[j].getElementsByTagName("span"); if (cells.length > 0) {
totVal = Number(totVal) + Number(cells[0].innerHTML);
}
}
rows[rows.length - 1].getElementsByTagName("span")[0].innerHTML =CurrencyFormatted(totVal);
}
catch (er) {
// Non-critical error
alert(er.description);
}
}