Imports System.Configuration.ConfigurationManager
Public Function syncrhonizeJSParametersWithWebConfig() As String
Dim jsConfigure As String = "<script language=""text/javascript"" type=""text/javascript"">" & vbCrLf & "<!--" & vbCrLf & "/* Written by: Joe McCormack. This Javascript Block Genereated by the .Net Custom Function syncrhonizeJSParametersWithWebConfig() */" & vbCrLf
Dim key As String = String.Empty, keyName As String = String.Empty, keyValue As String = String.Empty
For Each key In AppSettings.AllKeys
keyName = key : keyValue = System.Configuration.ConfigurationManager.AppSettings(key)
If InStr(LCase(keyName), "tojs_") - 1 > -1 Then
If IsNumeric(keyValue) Then
jsConfigure = jsConfigure & "var " & Replace(keyName, "tojs_", "") & " = " & keyValue & ";" & vbCrLf
Else
keyValue = Replace(keyValue, "<", "<")
keyValue = Replace(keyValue, ">", ">")
keyValue = Replace(keyValue, """, """")
jsConfigure = jsConfigure & "var " & Replace(keyName, "tojs_", "") & " = " & """" & keyValue & """;" & vbCrLf
End If
End If
Next key
jsConfigure = jsConfigure & "//-->" & vbCrLf & "</script>" & vbCrLf
Return jsConfigure
End Function
|