1
Dynamically Set Location
Question asked by David Richardson - 5/18/2018 at 6:37 PM
Answered
I want to be able to set the root path dynamically using session variables. The issue is Location will not except any ASP code and reads it as being NULL or Illegal characters.  Is there an easier way to set dynamic location? It will not allow me to place any asp tags. What is an alternative way to accomplish this?
GleamTech:FileManagerRootFolder Location="<% Response.write(sPath) %>

1 Reply

Reply to Thread
0
Cem Alacayir Replied
Employee Post Marked As Answer
ASP.NET tags only allow constant values inside properties (this is how ASP.NET WebForms is designed).
So you should do this; in aspx file:
 
<GleamTech:FileManagerControl ID="fileManager" runat="server" />

Then in codebehind (aspx.vb) or in a code block in the aspx file (between <% %>), adjust the properties dynamically:
 
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    'Create a root folder and add it to the control
    Dim rootFolder1 = New FileManagerRootFolder()
    rootFolder1.Name = "Root Folder 1"
    rootFolder1.Location = "~/App_Data/RootFolder1"
    fileManager.RootFolders.Add(rootFolder1)
    
    Dim accessControl1 = New FileManagerAccessControl()
    accessControl1.Path = "\"
    accessControl1.AllowedPermissions = FileManagerPermissions.Full
    rootFolder1.AccessControls.Add(accessControl1)
End Sub
 

Reply to Thread