Wednesday, December 10, 2008
Edit document from dataview
<a href="{@FileRef}" onclick="return DispEx(this,event,'TRUE','FALSE','TRUE','SharePoint.OpenDocuments.3','0','SharePoint.OpenDocuments','','','','1','0','0','0x7fffffffffffffff')"><xsl:value-of select="@FileLeafRef" /></a>
Tuesday, December 2, 2008
Redirecting from NewForm.aspx to DispForm.aspx after creating a new item
public class CustomEventReceiver : SPItemEventReceiver
{
private HttpContext _currentContext = null;
public CustomEventReceiver () : base ()
{
if (null != HttpContext.Current)
{
_currentContext = HttpContext.Current
}
}
public override void ItemAdding (SPItemEventProperties properties)
{
using(SPSite site = new SPSite(properties.SiteId))
{
using(SPWeb web = site.OpenWeb(properties.RelativeWebUrl))
{
SPList list = web.Lists[properties.ListId];
DisableEventFiring();
SPListItem itemToAdd = list.Items.Add();
foreach (SPField field in itemToAdd.Fields)
{
if (!field.Hidden && !field.ReadOnlyField && field != null && field.InternalName != "Attachments")
{
itemToAdd[field.InternalName] = properties.AfterProperties[field.InternalName];
}
}
itemToAdd.Update();
EnableEventFiring();
// Redirect
SPUtility.Redirect("/cn/Lists/Bills%20of%20Lading/DispForm.aspx?ID=" + itemToAdd.ID, SPRedirectFlags.Default, _currentContext);
}
}
}
}
{
private HttpContext _currentContext = null;
public CustomEventReceiver () : base ()
{
if (null != HttpContext.Current)
{
_currentContext = HttpContext.Current
}
}
public override void ItemAdding (SPItemEventProperties properties)
{
using(SPSite site = new SPSite(properties.SiteId))
{
using(SPWeb web = site.OpenWeb(properties.RelativeWebUrl))
{
SPList list = web.Lists[properties.ListId];
DisableEventFiring();
SPListItem itemToAdd = list.Items.Add();
foreach (SPField field in itemToAdd.Fields)
{
if (!field.Hidden && !field.ReadOnlyField && field != null && field.InternalName != "Attachments")
{
itemToAdd[field.InternalName] = properties.AfterProperties[field.InternalName];
}
}
itemToAdd.Update();
EnableEventFiring();
// Redirect
SPUtility.Redirect("/cn/Lists/Bills%20of%20Lading/DispForm.aspx?ID=" + itemToAdd.ID, SPRedirectFlags.Default, _currentContext);
}
}
}
}
Subscribe to:
Posts (Atom)