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);
}
}
}
}
Thursday, November 20, 2008
Errors were found when compiling the workflow.The workflow files were saved but cannot be run.
Check web.config file authorizedTypes section.
Friday, November 14, 2008
JavaScript: Get URL Parameters
var _GET={};
for(var m, v=location.href.split(/[?&]/), k=v.length-1;k>0;k--)
_GET[(m=v[k].split(/[=#]/))[0].toLowerCase()] = m.length>1?decodeURI(m[1]):"";
example:
mypage.aspx?MyParameter=2
var param=_GET.myparameter; (always use lowercase)
for(var m, v=location.href.split(/[?&]/), k=v.length-1;k>0;k--)
_GET[(m=v[k].split(/[=#]/))[0].toLowerCase()] = m.length>1?decodeURI(m[1]):"";
example:
mypage.aspx?MyParameter=2
var param=_GET.myparameter; (always use lowercase)
Tuesday, November 11, 2008
focus field javascript
<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("addAttributes");
function addAttributes() {
var control = document.getElementsByName("WPQ2accountsSearch");
if(control.length > 0)
{
control.item(0).focus();
}
}
</script>
_spBodyOnLoadFunctionNames.push("addAttributes");
function addAttributes() {
var control = document.getElementsByName("WPQ2accountsSearch");
if(control.length > 0)
{
control.item(0).focus();
}
}
</script>
Monday, October 20, 2008
401 Unauthorized, WebServices, Sharepoint
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(web.Site.ID))
{
// do things assuming the permission of the "system account"
}
});
{
using (SPSite site = new SPSite(web.Site.ID))
{
// do things assuming the permission of the "system account"
}
});
Wednesday, October 15, 2008
Subscribe to:
Posts (Atom)
