********************************************************************** Tip of the Day!by Sandra Gopikrishna Request object of ASP exposes a collection called clientcertificate using which the details of the client certificate can be retrieved. The following piece of code demonstrates the method of retrieving the values present in such a client certificate collection<% for each cfield in Request.clientCertificate Response.write "Certificate Field Name is :" & cfield & vbcrlf Response.write "Certificate Field values is :" & Request.clientCertificate(cfield) & vbcrlf next%> ********************************************************************** Tip of the Day!by Sandra Gopikrishna Session object has an important property called LCID, using which the date and currency settings of the page can be changed to reflect the given locale. The following piece of code explains this fact.<% 'collect a list of localeid's in an arraydim localeids localeids = Array (2048,1030,1031,1033,1034,1035,1036,1039,1040) 'continue executing next statement when an error occurs on error resume next 'Loop all the localeids and display the date and currency in this location in a suitable formatfor i =0 to ubound(localeids) localeid = localeids(i) session.LCID = localeid Response.write "Locale Id of this location : " & localeid & "
" Response.write "Date in short format in this location : " & date & "
" Response.write "Date in Long Format in this location : " & FormatDateTime(date,vblongdate) & "
" Response.write "Currency as tested in this location is : " & Formatcurrency(834.5) & "
"next%> ********************************************************************** Tip of the Day!by Sandra Gopikrishna Session object has an important property called LCID, using which the date and currency settings of the page can be changed to reflect the given locale. The following piece of code explains this fact.<% 'collect a list of localeid's in an arraydim localeids localeids = Array (2048,1030,1031,1033,1034,1035,1036,1039,1040) 'continue executing next statement when an error occurs on error resume next 'Loop all the localeids and display the date and currency in this location in a suitable formatfor i =0 to ubound(localeids) localeid = localeids(i) session.LCID = localeid Response.write "Locale Id of this location : " & localeid & "
" Response.write "Date in short format in this location : " & date & "
" Response.write "Date in Long Format in this location : " & FormatDateTime(date,vblongdate) & "
" Response.write "Currency as tested in this location is : " & Formatcurrency(834.5) & "
"next%> ********************************************************************** Tip of the Day!by Ian Vink If you need to loop though a set of check boxes, to see which ones are checked, use the length property less one. In this example, the form is called, "frmSets" and the checkboxes are called "SetNo". The values of the checkboxes are added to a variable for splitting later. dim iLen iLen = frmSets.SetNo.length-1 for i = 0 to iLen if frmSets.SetNo.item(i).checked then x = x + frmSets.SetNo.item(i).value + "," end if next ********************************************************************** Tip of the Day! by Srinivasa Sivakumar Function ShowSystemDrivers(vComputerName) Dim objLocator, objService, objWEBMCol, objWEBM Set objLocator = CreateObject("WbemScripting.SWbemLocator") 'Establish a connection to WMI If isEmpty(vComputerName) = True then Set objService = objLocator.ConnectServer Else Set objService = objLocator.ConnectServer(vComputerName) End If 'Get the Webm Service object Set objWEBMCol = objService.InstancesOf("Win32_SystemDriver") Response.write "

Windows Base Service System Driver:


" 'Clean up Set objLocator = Nothing Set objService = Nothing Set objWEBMCol = Nothing Set objWEBM = Nothing End Function Note: Pass the computer name as the parameter. An empty string will work when you are accessing the local computer. ********************************************************************** Tip of the Day! by Srinivasa Sivakumar Function ShowSystemAccounts(vComputerName) Dim objLocator, objService, objWEBMCol, objWEBM Set objLocator = CreateObject("WbemScripting.SWbemLocator") 'Establish a connection to WMI If isEmpty(vComputerName) = True then Set objService = objLocator.ConnectServer Else Set objService = objLocator.ConnectServer(vComputerName) End If 'Get the Webm Service object Set objWEBMCol = objService.InstancesOf("Win32_SystemAccount") Response.write "

Windows System Accounts:


" 'Clean up Set objLocator = Nothing Set objService = Nothing Set objWEBMCol = Nothing Set objWEBM = Nothing End Function Note: Pass the computer name as the parameter. An empty string will work when you are accessing the local computer. ********************************************************************** Tip of the Day!by Sandra Gopikrishna Microsoft Word Application Exposes a lot of usefull intrerfaces for ASP and VB. One such interface is GetSpellingSuggestions.This Method helps us to get the spelling suggestions for the supplied word by employing Microsoft Word Application. The following example shows the method of accessing the 'GetSpellingSuggestions' interface exposed by Microsoft word application from ASP.spellsuggest.asp-------------------------<% set wordapp = server.createobject("Word.Application") wordapp.documents.add word_str = "manitest" set suggestions = wordapp.GetSpellingSuggestions(word_str) Response.write " The Supplied Word has Following Spelling Suggestions From Microsoft Word:
" for each suggestion in suggestions Response.write("
") Response.write suggestion & "
" next wordapp.quit set wordapp = nothing%> In the following example the word 'manifest' is wrongly typed as 'manitest' and is sent to the GetSpellingSuggestion() method exposed by microsoft word , and the suggestions returned by this method are displayed on the asp page. Note: In Order for the following example to work Microsoft Word should be installed on the machine hosting the webserver. ********************************************************************** Tip of the Day!by S Bashkar ASP.NET offers a powerfull application framework for the web developer by providing the concept of server controls. Using these server controls we can control almost every thing that needs to be sent to the clients browser.The following ASP.NET code snippet demonstrates a method of creating a textarea by employing the 'TextMode' property of server control. It should be noted that in the absence of TextMode property in the server control generates a TextBox input control on the client.multitxt.aspx--------------

Multiline text box Control generated by ASP.NET

********************************************************************** Tip of the Day!by Sandra Gopikrishna The following server varaiable helps us in finding out the instance of iis that is attending the current request of client.<% response.write "Your request is being attended by the following" &_ "instance of IIS
"response.write request.servervariables("INSTANCE_ID") %> ********************************************************************** Tip of the Day! by Srinivasa Sivakumar Function DeleteShare(vComputerName, vAliasName) Dim objLocator, objService, objWEBMCol Set objLocator = CreateObject("WbemScripting.SWbemLocator") 'Establish a connection to WMI If isEmpty(vComputerName) = True then Set objService = objLocator.ConnectServer Else Set objService = objLocator.ConnectServer(vComputerName) End If 'Get the Webm Service object Set objWEBMCol = objService.Get("Win32_Share.Name=" & vAliasName) 'Check the object variable If objWEBMCol Is Nothing Then Response.write "Unable get the handle of the Share process" Else 'Kill the share if objWEBMCol.Delete = 0 then Response.write "Done! " Else Response.write "There was an error occurred!" End if End if 'Clean up Set objLocator = Nothing Set objService = Nothing Set objWEBMCol = Nothing End Function Note: Pass the computer name as the parameter. An empty string will work when you are accessing the local computer. The parameter vAliasName describes the alias name for the shared resource. Call DeleteShare (“”, "MyDocuments") ********************************************************************** Tip of the Day! by Srinivasa Sivakumar Function ShowProgramGroupOrItem(vComputerName) Dim objLocator, objService, objWEBMCol, objWEBM Set objLocator = CreateObject("WbemScripting.SWbemLocator") ‘Establish a connection to WMI If isEmpty(vComputerName) = True then Set objService = objLocator.ConnectServer Else Set objService = objLocator.ConnectServer(vComputerName) End If ‘Get the Webm Service object Set objWEBMCol = objService.InstancesOf("Win32_ProgramGroupOrItem") Response.write "

Program Items in Start/Programs menu:


    " ‘Enumerate For Each objWEBM in objWEBMCol Response.write "
  • Name: " & objWEBM.Name & _ ",
    Caption: " & objWEBM.Caption & _ ",
    Description: " & objWEBM.Description & _ ",
    Status: " & objWEBM.Status & "
  • " Next Response.write "
" ‘Clean up Set objLocator = Nothing Set objService = Nothing Set objWEBMCol = Nothing Set objWEBM = Nothing End Function Note: Pass the computer name as the parameter. An empty string will work when you are accessing the local computer. ********************************************************************** Tip of the Day! by Sandra Gopikrishna The following piece of code helps us to find out whether the client request is sent to secure port of webserver or not. If it is sent to secure port of webserver 'request.servervariables("SERVER_PORT_SECURE")' returns 1 else 0 <% response.write "Is your request submitted to secure port of the webserver" &_ ( 0 indicates No / 1 Indicates Yes) ?
" response.write (request.servervariables("SERVER_PORT_SECURE")) %> ********************************************************************** Tip of the Day! by Srinivasa Sivakumar Function ShowProgramGroup(vComputerName) Dim objLocator, objService, objWEBMCol, objWEBM Set objLocator = CreateObject("WbemScripting.SWbemLocator") ‘Establish a connection to WMI If isEmpty(vComputerName) = True then Set objService = objLocator.ConnectServer Else Set objService = objLocator.ConnectServer(vComputerName) End If ‘Get the Webm Service object Set objWEBMCol = objService.InstancesOf("Win32_ProgramGroup") Response.write "

Program Groups in the Start Menu:


    " ‘Enumerate For Each objWEBM in objWEBMCol Response.write "
  • Name: " & objWEBM.Name & _ ",
    Caption: " & objWEBM.Caption & _ ",
    Description: " & objWEBM.Description & _ ",
    Setting ID: " & objWEBM.SettingID & _ ",
    Group Name: " & objWEBM.GroupName & _ ",
    Who can access: " & objWEBM.UserName & "
  • " Next Response.write "
" ‘Clean up Set objLocator = Nothing Set objService = Nothing Set objWEBMCol = Nothing Set objWEBM = Nothing End Function Note: Pass the computer name as the parameter. An empty string will work when you are accessing the local computer. ********************************************************************** Tip of the Day! by Ian Vink To connect to an Access database you need to set the "connectionstring" property of the Connection object: [Note the connection object is created with: server.createobject("ADODB.connection") ] However if you are on an ISP that periodically changes the physical path to your virtual directory, your scripts will break. The solution is to get the path dynamically. <% Dim AppPath, DatabasePath AppPath = Request.ServerVariables("APPL_PHYSICAL_PATH") DatabasePath = AppPath & "db\customers.mdb" %> The full path to the database is now calculated and your ISP can change your virtual directory all they want. ********************************************************************** Tip of the Day! by Sandra Gopikrishna ASP.NET offers a couple of methods for determining the type of browser thats being employed by the client. One Such method of doing so, is by employing the HttpBrowserCapabilities class. HttpBrowserCapabilities class exposes all of the properties that the ASP 3.0 with some more extra features. The following piece of code demonstrates the method of using HttpBrowserCapabilities in sniffing the browser thats being employed by the client. sniffbrow.aspx -------------- <%@ page language = "VB"%> <% Dim bcobj As HttpBrowserCapabilities = Request.Browser If bcobj.Browser = "IE" Then Response.write("The client is using InternetExplorer") Else Response.write("The client is not using InternetExplorer") End If %> ********************************************************************** Tip of the Day! by Ian Vink When writing XML in an ASP page for display in a browser, add this line to tell the browser it should interpret the data as XML. <% response.ContentType = "text/xml" %> ********************************************************************** Tip of the Day! by Srinivasa Sivakumar How to list all Logical Program Groups from ASP? Function ShowLogicalProgramGroups(vComputerName) Dim objLocator, objService, objWEBMCol, objWEBM Set objLocator = CreateObject("WbemScripting.SWbemLocator") ‘Establish a connection to WMI If isEmpty(vComputerName) = True then Set objService = objLocator.ConnectServer Else Set objService = objLocator.ConnectServer(vComputerName) End If ‘Get the Webm Service object Set objWEBMCol = objService.InstancesOf("Win32_LogicalProgramGroup") Response.write "

Logical Program Groups:


    " ‘Enumerate For Each objWEBM in objWEBMCol Response.write "
  • Name: " & objWEBM.Name & _ ",
    Caption: " & objWEBM.Caption & _ ",
    Description: " & objWEBM.Description & _ ",
    Group Name: " & objWEBM.GroupName & _ ",
    Who can access: " & objWEBM.UserName & _ ",
    Status: " & objWEBM.Status & "
  • " Next Response.write "
" ‘Clean up Set objLocator = Nothing Set objService = Nothing Set objWEBMCol = Nothing Set objWEBM = Nothing End Function Note: Pass the computer name as the parameter. An empty string will work when you are accessing the local computer. **********************************************************************