API/CodeSamples/SettingsKey.md
... ...
@@ -0,0 +1,57 @@
1
+#SettingsKey
2
+
3
+[[_TOC_]]
4
+
5
+##About
6
+
7
+Gets or sets password to access the settings page. It should be used in tandem with UserKey if you don't need multi-user security.
8
+If set, user will be asked for the password before settings page will be opened.
9
+
10
+##Global.asax (C♯)
11
+
12
+```csharp
13
+//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig
14
+public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig
15
+{
16
+ // Configure settings
17
+ // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method
18
+ public static void InitializeReporting() {
19
+ //Check to see if we've already initialized.
20
+ if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null)
21
+ return;
22
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE";
23
+ //Creates a connection to Microsoft SQL Server
24
+ AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE";
25
+ Izenda.AdHoc.AdHocSettings.AdHocConfig = new CustomAdHocConfig();
26
+ AdHocSettings.ShowSettingsButton = true; //the relevant setting
27
+ HttpContext.Current.Session["ReportingInitialized"] = true;
28
+ }
29
+}
30
+```
31
+
32
+##Global.asax (VB.NET)
33
+
34
+```visualbasic
35
+'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig
36
+Public Class CustomAdHocConfig
37
+ Inherits Izenda.AdHoc.DatabaseAdHocConfig
38
+
39
+ 'Configure settings
40
+ 'Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method
41
+ Shared Sub InitializeReporting()
42
+ 'Check to see if we've already initialized.
43
+ If HttpContext.Current.Session Is Nothing OrElse HttpContext.Current.Session("ReportingInitialized") IsNot Nothing Then
44
+ Return
45
+ 'Initialize System
46
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"
47
+ AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"
48
+ Izenda.AdHoc.AdHocSettings.AdHocConfig = New CustomAdHocConfig()
49
+ AdHocSettings.ShowSettingsButton = True 'The relevant setting
50
+ HttpContext.Current.Session("ReportingInitialized") = True
51
+ End Sub
52
+End Class
53
+```
54
+
55
+##Screenshots
56
+
57
+![](http://wiki.izenda.us/API/CodeSamples/SettingsKey/settings_key.png)
... ...
\ No newline at end of file