- Download the cab file here.
- Edit the frame.htm file and chnage the path of the cabfile. Note: For some crazy reason the folder that contains the files for your html published PowerPoint presentation is hidden when you are running it from a SharePoint site. Thus you must open the original .ppt file and 'Save As' the PowerPoint presentation in .htm to your DESKTOP and then edit the "frame.htm" file in the folder that it creates. In the frame.htm search for:
http://download.microsoft.com/download/PowerPoint2002/Install/10.0.2609/WIN98MeXP/EN-US/msorun.cab#version=11,0,0,1
and change it to:msorun.cab#version=11,0,0,1
This will make the path to the cab file the same as all the other files (secured) and relative to the frame.htm document. - Place the cab file in the PowerPoint folder that is on your desktop.
- Upload the whole thing (xxxx.htm, and the PowerPoint folder) to your sharepoint site.
PS-The msorun.cab file is used for PowerPoint animations.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
// How many rows when the page initially loads.
static int tDefaultRow_Count = 10;
// Max number of rows.
static int tMaxRows = 50;
// Do not modify the following.
private int tUserAddedRowCount = 0;
static TextBox[] TextBox_Item = new TextBox[tMaxRows];
static TextBox[] TextBox_Desc = new TextBox[tMaxRows];
static TextBox[] TextBox_Quantity = new TextBox[tMaxRows];
static TextBox[] TextBox_Price = new TextBox[tMaxRows];
static TextBox[] TextBox_Total = new TextBox[tMaxRows];
protected void Page_Load(object sender, EventArgs e)
{
tUserAddedRowCount = (ViewState["tUserAddedRowCount"] != null) ? int.Parse(ViewState["tUserAddedRowCount"].ToString()) : 0;
//Response.Write("User Rows: " + tUserAddedRowCount + "\r\n");
// Recreate the extra rows created by the user on postback
// events (required to maintain state).
Add_Table_Rows(tUserAddedRowCount + tDefaultRow_Count);
}
protected void Button1_Click(object sender, EventArgs e)
{
// User clicked "add a row" button.
Add_Table_Rows(1);
ViewState["tUserAddedRowCount"] = ++tUserAddedRowCount;
}
protected void Button2_Click(object sender, EventArgs e)
{
// User clicked "Submit" button.
for (int x = 0; x < tDefaultRow_Count + tUserAddedRowCount; x++)
{
if (TextBox_Item[x].Text.ToString().Length > 0)
{
Response.Write(TextBox_Item[x].Text.ToString());
Response.Write(TextBox_Desc[x].Text.ToString());
Response.Write(TextBox_Quantity[x].Text.ToString());
Response.Write(TextBox_Price[x].Text.ToString());
Response.Write(TextBox_Total[x].Text.ToString());
}
}
}
private void Add_Table_Rows(int NumberOfRows)
{
for (int x = 0; x < NumberOfRows; x++)
{
TableRow myRow = new TableRow();
Table1.Rows.Add(myRow);
TableCell myCell0 = new TableCell();
myRow.Cells.Add(myCell0);
TextBox myTextbox0 = new TextBox();
TextBox_Item[x] = myTextbox0;
myCell0.Controls.Add(TextBox_Item[x]);
TableCell myCell1 = new TableCell();
myRow.Cells.Add(myCell1);
TextBox myTextbox1 = new TextBox();
TextBox_Desc[x] = myTextbox1;
myCell1.Controls.Add(TextBox_Desc[x]);
TableCell myCell2 = new TableCell();
myRow.Cells.Add(myCell2);
TextBox myTextbox2 = new TextBox();
TextBox_Quantity[x] = myTextbox2;
myCell2.Controls.Add(TextBox_Quantity[x]);
TableCell myCell3 = new TableCell();
myRow.Cells.Add(myCell3);
TextBox myTextbox3 = new TextBox();
TextBox_Price[x] = myTextbox3;
myCell3.Controls.Add(TextBox_Price[x]);
TableCell myCell4 = new TableCell();
myRow.Cells.Add(myCell4);
TextBox myTextbox4 = new TextBox();
TextBox_Total[x] = myTextbox4;
myCell4.Controls.Add(TextBox_Total[x]);
}
}
}
Make sure to add your .NET reference to Windows SharePoint Services dll. This is a simple console app...
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
namespace UserNameListTester
{
class Program
{
static void Main(string[] args)
{
try
{
SPSite siteCollection = new SPSite("http://localhost");
SPWeb mySite = siteCollection.OpenWeb("/");
SPListItemCollection listItems = mySite.Lists["UserNameListTester"].Items;
Console.WriteLine("Read in the existing values****************************");
for (int i = 0; i < listItems.Count; i++)
{
SPListItem item = listItems[i];
Console.WriteLine(item["PersonOrGroupColumn"].ToString());
}
Console.WriteLine("Writing new values**************************************");
for (int i = 0; i < listItems.Count; i++)
{
SPListItem listItem = listItems[i];
//listItem["Created By"] = mySite.Users["domain\\cornwell"];
// get the current logged on user
string currentUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
listItem["Created By"] = mySite.Users[currentUser];
listItem.Update();
}
Console.WriteLine("Read out changed values*******************************");
for (int i = 0; i < listItems.Count; i++)
{
SPListItem item = listItems[i];
Console.WriteLine(item["PersonOrGroupColumn"].ToString());
}
}
catch (Exception ex)
{
Console.WriteLine("Shit: " + ex.Message.ToString() + ex.Source.ToString() + ex.ToString());
}
finally
{
string foo = Console.ReadLine();
}
}
}
}
How to enable debugging in WSS 3.0 Renaud Comte has a great tip on how to get the full ASP.NET errors appearing in WSS 3.0. The detail is to add the following item to your Web.Config (C:\Inetpub\wwwroot\wss\VirtualDirectories\80):
<!-- Becomes -->
<SafeMode MaxControls="200" CallStack="true" ...>
<customErrors mode="On" />
<!-- Becomes -->
<customErrors mode="Off" />
<compilation batch="false" debug="false">
<!-- Becomes -->
<compilation batch="true" debug="true">
I found this blog on how to do it.
Here is the basic idea..
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
private PeopleEditor objEditor;
protected void Page_Load(object sender, EventArgs e)
{
objEditor = new PeopleEditor();
objEditor.AutoPostBack = true;
objEditor.PlaceButtonsUnderEntityEditor = true;
objEditor.ID = "pplEditor";
objEditor.AllowEmpty = false;
objEditor.SelectionSet = "User,SecGroup,SPGroup";
objEditor.MultiSelect = false;
Panel1.Controls.Add(objEditor);
}
private string GetAccountName()
{
string strAccountName = String.Empty;
for (int i = 0; i < objEditor.ResolvedEntities.Count; i++)
{
PickerEntity objEntity = (PickerEntity)objEditor.ResolvedEntities[i];
SPUserInfo objInfo = new SPUserInfo();
objInfo.LoginName = objEntity.Key;
strAccountName = objInfo.LoginName;
// to return a sharepoint people group formatted string use...
// strAccountName = objEntity.EntityData["SPUserID"].ToString() + ";#" + objEntity.DisplayText.ToString();
}
return strAccountName;
}
protected void Button1_Click(object sender, EventArgs e)
{
string strAccountName = GetAccountName();
Label1.Text = "account name: " + strAccountName;
}
}
Or via HTML:
AutoPostBack="true" AllowEmpty="false" SelectionSet="User,SecGroup,SPGroup"
BorderWidth="1" Width="200px" PlaceButtonsUnderEntityEditor="false" Rows="1" />
For this code to work you must publish it to a SharePoint website. You cannot run it from the Visual Studio debugger.
Add the following line to the post build command list. It will publish the dll to the SharePoint site, reset IIS (clearing the cached object), and open IE.
xcopy "*.dll" "C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin\" /y
iisreset
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://localhost/mydevsite/
Edit as needed.
In order for a user to perform tasks on a SharePoint site that require higher permissions than they have, you can use "RunWithElevateedPrivileges" method of the SPSecurity object. The account used is assumed to be the "system account".
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// CODE TO RUN WITH ELEVATED PRIVILEGES GOES HERE //
SPSite siteCollection = new SPSite("https://foobar.com");
SPWeb mySite = siteCollection.AllWebs["tpms/review"];
mySite.AllowUnsafeUpdates = true;
SPWeb rootSite = siteCollection.OpenWeb("/");
SPListItemCollection myList = mySite.Lists["Performance Improvement Notice Tasking"].Items;
SPListItem updateItem = myList.GetItemById((int)globalIdNumber);
updateItem["Title"] = "Foobar";
updateItem.Update();
mySite.Dispose();
rootSite.Dispose();
// END ELEVATED CODE BLOCK //
});
This mean no more .credentials auth crap.