EditDocumentLink Class
System.Object
System.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.HyperLink
Microsoft.SharePoint.WebControls.EditDocumentLink
System.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.HyperLink
Microsoft.SharePoint.WebControls.EditDocumentLink
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
EditDocumentLink
Description
The Microsoft.SharePoint.WebControls.EditDocumentLink class inherits from the System.Web.UI.WebControls.HyperLink class to build a link to another WebPage to render to standard output, specifying that the target attribute should be specified through HtmlTextWriterAttribute.Target.
The EditDocumentLink control functions by expecting a document URL to be provided, representing the path to a document object. Once this and the SPWeb (automatically garnished from the current Context), this can be used with the SPUtility.GetIsecurableObjectFromUrl method to build a new Microsoft.SharePoint.ISecurableObject object. Once a new ISecurableObject is hydrated, permissions can be tested using the DoesUserHavePermissions method passing in the SPBasePermissions with UseClientIntegration to ensure document integration.
It should be noted that the EditDocumentLink.IsXmlForm property is checked through multiple gates because the document will be treated differently for rendering, therefore it is important to set this property.
Ultimately, EditDocumentLink builds out a link to the document object along with the functionality depending on permissions and document type.
Usage Scenario
The EditDocumentLink control has heavy representation when using custom rendering templates, as well as when building interfaces into document repositories. Because the control contains no context bound properties, such as ItemContext within FormComponent context, it can be used analogous to other WebControls. Because of this loose coupling, the class is most useful when working with document related development.
In the below example, MyClass is inheriting from the System.Web.UI.WebControls.WebParts.WebPart class and its CreateChildControls method is being overridden. Following, a new EditDocumentLink object is being created. The EditDocumentLink.DocumentUrl is being set to a fictitious string, however must represent a path to document object and the EditDocumentLink.IsXmlForm property if being set to false. Following, the EditDocumentLink object is then added to the current instance control collection.
C# Code Example
public class MyClass : WebPart
{
protected override void CreateChildControls()
{
EditDocumentLink link = new EditDocumentLink();
link.DocumentUrl = "<Some URL>";
link.IsXmlForm = false;
Controls.Add(link);
base.CreateChildControls();
}
}
VB.NET Code Example
Public Class [MyClass]
Inherits WebPart
Protected Overloads Overrides Sub CreateChildControls()
Dim link As New EditDocumentLink()
link.DocumentUrl = "<Some URL>"
link.IsXmlForm = False
Controls.Add(link)
MyBase.CreateChildControls()
End Sub
End Class
Adam Buenz
SharePoint Services MVP - http://www.sharepointsecurity.com
The Microsoft.SharePoint.WebControls.EditDocumentLink class inherits from the System.Web.UI.WebControls.HyperLink class to build a link to another WebPage to render to standard output, specifying that the target attribute should be specified through HtmlTextWriterAttribute.Target.
The EditDocumentLink control functions by expecting a document URL to be provided, representing the path to a document object. Once this and the SPWeb (automatically garnished from the current Context), this can be used with the SPUtility.GetIsecurableObjectFromUrl method to build a new Microsoft.SharePoint.ISecurableObject object. Once a new ISecurableObject is hydrated, permissions can be tested using the DoesUserHavePermissions method passing in the SPBasePermissions with UseClientIntegration to ensure document integration.
It should be noted that the EditDocumentLink.IsXmlForm property is checked through multiple gates because the document will be treated differently for rendering, therefore it is important to set this property.
Ultimately, EditDocumentLink builds out a link to the document object along with the functionality depending on permissions and document type.
Usage Scenario
The EditDocumentLink control has heavy representation when using custom rendering templates, as well as when building interfaces into document repositories. Because the control contains no context bound properties, such as ItemContext within FormComponent context, it can be used analogous to other WebControls. Because of this loose coupling, the class is most useful when working with document related development.
In the below example, MyClass is inheriting from the System.Web.UI.WebControls.WebParts.WebPart class and its CreateChildControls method is being overridden. Following, a new EditDocumentLink object is being created. The EditDocumentLink.DocumentUrl is being set to a fictitious string, however must represent a path to document object and the EditDocumentLink.IsXmlForm property if being set to false. Following, the EditDocumentLink object is then added to the current instance control collection.
C# Code Example
public class MyClass : WebPart
{
protected override void CreateChildControls()
{
EditDocumentLink link = new EditDocumentLink();
link.DocumentUrl = "<Some URL>";
link.IsXmlForm = false;
Controls.Add(link);
base.CreateChildControls();
}
}
VB.NET Code Example
Public Class [MyClass]
Inherits WebPart
Protected Overloads Overrides Sub CreateChildControls()
Dim link As New EditDocumentLink()
link.DocumentUrl = "<Some URL>"
link.IsXmlForm = False
Controls.Add(link)
MyBase.CreateChildControls()
End Sub
End Class
Adam Buenz
SharePoint Services MVP - http://www.sharepointsecurity.com
- 5/18/2010
- Adam Buenz - MVP