Dynamicweb 8 Documentation
LoopExists Method
Example 

The name of loop to check for.
Checks if a loop exists in the loaded template.
Syntax
'Declaration
 
Public Function LoopExists( _ 
   ByVal name As String _ 
) As Boolean
public bool LoopExists( 
   string name 
)

Parameters

name
The name of loop to check for.

Return Value

true if the loop is found in the template; otherwise false
Remarks
Used for optimizing performance. If the loop is expensive to render, there is no need to execute the code if the template is not going to use the data.
Example
Use LoopExists to avoid expensive operations
'Load a template from /Files/Templates/MyFolder/MyTemplate.html
Dim t As New Template("MyFolder/MyTemplate.html")
'Set a tag value 
t.SetTag("MyTag", "Hello world!")
'Check if the loop exists in template before getting the data
If t.LoopExists("MyLoop") Then
Dim loopTemplate As Template = t.GetLoop("MyLoop")
For Each p As Content.Page In Content.Page.GetPagesByAreaID(1)
	loopTemplate.SetTag("PageName", p.MenuText)
	loopTemplate.CommitLoop()
Next
End If
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Template Class
Template Members

Send Feedback