Sitefinity 4.1 List in VB
Hi
I have a list in sitefinity which I am trying to access with a code behind in a master template
My list is called 'FAQ'
My VB is
Imports Telerik.Sitefinity.Modules.ListsImports Telerik.Sitefinity.Lists.ModelPublic Class InsiderControl Inherits System.Web.UI.UserControl Public Function FindList(ByVal listTitle As String) As List Dim manager As ListsManager = ListsManager.GetManager() Dim listToLocate As List = manager.GetLists().Where(Function(l) l.Title = listTitle).[Single]() Return listToLocate End Function Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Register styles ScriptManager.RegisterStartupScript(Me.Page, GetType(Page), "insiderControlStyles", String.Format("<link rel='stylesheet' media='screen' type='text/css' href='0' />", ResolveUrl("InsiderArea.css")), False) 'Registers javascript/jQuery ScriptManager.RegisterStartupScript(Me.Page, GetType(Page), "insiderControl", String.Format("<script src='0' type='text/javascript'></script>", ResolveUrl("InsiderControl.js")), False) FindList("FAQ") End SubEnd Class'Manager.GetLists().Where(Function(l) l.Title = listTitle).[Single]()'Hello Andrew,
The Title property of built in modules is of type LString in order to support localization. While C# allows the comparing of LString with string directly in VB you have to explicitly complare the Value property of the LString type with the parameter:
Manager.GetLists().Where(Function(l) l.Title.Value = listTitle)great, thats sorted it
Thanks
or at least I thought it hade sorted the issue
I am now getting the error
Property 'System.String Value' is not defined for type 'System.String'Hello Andrew,
Can you please check the Where statement? Are you using Title again? If you are filtering for some other field it might be declared as a string, so Value is not needed there. Please check the return type of the property. Also try to declare the filtering parameters as local variables:
Public Function FindList(ByVal listTitle As String) As List Dim manager As ListsManager = ListsManager.GetManager() Dim titleToFind As String = listTitle Dim listToLocate As List = manager.GetLists().Where(Function(l) l.Title = titleToFind).[Single]() Return listToLocateEnd FunctionMaybe try GetLists().ToList().Where....