Jump to content
  • B.1 - Usage outside call routing - Simple ASP webpage

    B.1 - Usage outside call routing - Simple ASP webpage

    VBScript   1.1.0


    This example demonstrates how to make use of Persistent Variables in an ASP (Active Server Page) web page.


    You will find it in the download package in the following folder

    • \examples\External\asp


    This little web page is meant to be used within a WebExtension in a SwyxIt! skin.


    It displays the current status of the installed Night Switch example (see chapters A.1 and A2).


    By clicking into the web page the status of the night switch will be toggled. The page also refreshes itself every 2 seconds, so if the night switch is getting switched from somewhere else, this page will also automatically shows the new status.





    <meta http-equiv="refresh" content="2;url=<%=Request.ServerVariables("SCRIPT_NAME")%>">
      body.on  { background: #FFFF00; }
      body.off { background: #C0C0C0; }
      a        { padding:    48% 50%; }
    <!-- #include file = "PersistentVariables.inc"-->
    	' configure the complete db connect string
    	g_sPersistentVariableConnectString = _
    		"Provider=sqloledb;" & _
    		"Data Source=WS-WELLIGE04;" & _
    		"Initial Catalog=" & PERSISTENT_VARIABLE_DATABASE & ";" & _
    		"User Id=PersistentVariables;" & _
    	' initialize persistent variable
    	Dim NightSwitch
    	Set NightSwitch     = new PersistentVariable
    	NightSwitch.Name    = "NightSwitch"
    	NightSwitch.Default = 0
    	' evaluate url parameter	
    	sUrlSwitch = Request.QueryString("switch")
    	if (sUrlSwitch <> "") and IsNumeric(sUrlSwitch) then NightSwitch.Value = CInt(sUrlSwitch)
    	' set display styles
    	if NightSwitch.Value = 0 then
    		sStyle  = "off"
    		sSwitch = "1"
    		sStyle  = "on"
    		sSwitch = "0"
    	end if
    	Set NightSwitch = Nothing
    	sURL = Request.ServerVariables("SCRIPT_NAME") & "?switch=" & sSwitch
    <body class="<%=sStyle%>">
    	<a href="<%=sURL%>"> </a>



    You have to make sure, that the PersistenVariables.inc file is in the same folder as the default.asp file.


    Please find a complete explanation of the usage of persistent variables outside of call routing scripts here:



    Tom Wellige


  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.