The Entity Framework is considered to be the modern day successor to "LINQ to SQL". If you wish to use this technology in a SharePoint 2007 web part you will need to tweak your web.config file to accomodate the new assemblies that are associated with the Entity Framework. Here are the changes that you need to apply to your web.config file:
1) Add the following tags to the <compilation><assemblies> section:
<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Entity.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
2) Add the following tags to the <compilation> section just under the closing </assemblies> tag:
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
</buildProviders>
Friday, March 6, 2009
Tuesday, March 3, 2009
How can you get the thumbnail for an image in your SharePoint picture library?
This is much easier than I had imagined. At first I thought I need to do some programming with the SharePoint Object Model APIs. It turned out to be nothing of the sort.
Let us assume that you have a photograph located in your picture library named "pictures" at this URL:
http://www.spserver.com/spsite/pictures/joe_smith.jpg
The thumbnail for the above picture is located at:
http://www.spserver.com/spsite/pictures/_t/joe_smith_jpg.jpg
As you can see, here's what I did:
1) tag a directory "_t" to the the URL just before the filename.
2) tag "_jpg" to the filename just before the extention. This would have been "_gif" if you are dealing with a GIF file.
Voila, if you point your browser to this tweaked URL you will get your thumbnail.
You will get a larger image if you use _w instead of _t.
Painless eh. . .
Let us assume that you have a photograph located in your picture library named "pictures" at this URL:
http://www.spserver.com/spsite/pictures/joe_smith.jpg
The thumbnail for the above picture is located at:
http://www.spserver.com/spsite/pictures/_t/joe_smith_jpg.jpg
As you can see, here's what I did:
1) tag a directory "_t" to the the URL just before the filename.
2) tag "_jpg" to the filename just before the extention. This would have been "_gif" if you are dealing with a GIF file.
Voila, if you point your browser to this tweaked URL you will get your thumbnail.
You will get a larger image if you use _w instead of _t.
Painless eh. . .
Wednesday, February 18, 2009
How to use JavaScript to close an IE7 browser window without seeing the confirmation dialog?
<a href="javascript: window.open('','_parent','');window.close();">Close this window!</a><br />
Thursday, December 4, 2008
What is a quick way to get a .NET assembly's PublicKeyToken?
The quick and dirty way is to go into the .NET command prompt and type the following:
sn -T MyDotNetAssembly.dll
The above utilizes the strong name utility that comes with the .NET Framework.
sn -T MyDotNetAssembly.dll
The above utilizes the strong name utility that comes with the .NET Framework.
Wednesday, November 26, 2008
Download tracking with WSS 3.0
WSS 3.0 does not have a mechanism for tracking who downloads which files with authenticated users. When I got confronted with this task, I decided to create a web user control that reads all the files in a document library and subsequently displays the file names using a series of "LinkButton" controls. I then attached this web user control to a SharePoint WSS 3.0 web page. I decided against using a Hyperlink object in favor of a LinkButton ASP.NET control for the following two reasons:
1) With a HyperLink ASP.NET control, users can right-click on the anchor and choose "Save target as" to save the file. This is not desirable because no event is triggered when that happens. On the other hand, a LinkButton control does not produce a right-click popup in a browser leaving the user with no choice but to click on the link.
2) I needed to put some business logic behind the click event of the LinkButton. The business logic essentially saves statistics along the lines of: timestamp, host address, user ID, and filename.
1) With a HyperLink ASP.NET control, users can right-click on the anchor and choose "Save target as" to save the file. This is not desirable because no event is triggered when that happens. On the other hand, a LinkButton control does not produce a right-click popup in a browser leaving the user with no choice but to click on the link.
2) I needed to put some business logic behind the click event of the LinkButton. The business logic essentially saves statistics along the lines of: timestamp, host address, user ID, and filename.
Wednesday, October 22, 2008
How to programatically delete a SharePoint 2007 field belonging to a list or document library?
Here's the code for deleting a field named "phone" in list "myList" on a site with URL http://mysite/:
try {
using (SPSite sitecollection = new SPSite("http://mysite/")) {
using (SPWeb web = sitecollection.OpenWeb()) {
web.AllowUnsafeUpdates = true;
// Delete Sharepoint SPField
web.Lists["myList"].Fields.Delete("phone");
web.Update();
Console.WriteLine("Done deleting column");
}
}
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
try {
using (SPSite sitecollection = new SPSite("http://mysite/")) {
using (SPWeb web = sitecollection.OpenWeb()) {
web.AllowUnsafeUpdates = true;
// Delete Sharepoint SPField
web.Lists["myList"].Fields.Delete("phone");
web.Update();
Console.WriteLine("Done deleting column");
}
}
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
Tuesday, October 21, 2008
How do you break up a long SharePoint 2007 survey?
What do you do if you have a long SharePoint 2007 survey and you want to break it up into separate pages such that the user needs to click the "Next" button?
Solution:
You must use branching on selected questions for this. All branching items would simply point to the next question. That produces a “Next” button.
Solution:
You must use branching on selected questions for this. All branching items would simply point to the next question. That produces a “Next” button.
Subscribe to:
Posts (Atom)