********************************************************************** Tip of the Day! by Ian Vink If you add the value of an XSL select element from an XML document to a hyperlink, start with a simple tag, then use the attribute command to add the HREF. DocsXML.asp ********************************************************************** Tip of the Day! by Srinivasa Sivakumar The TotalMemory property of the System.GC class will tell us the total memory available in our system. <% @Import Namespace="System " %> ********************************************************************** Tip of the Day! by Ian Vink To add an attribute to the HTML tag in XSL, you should use the Attribute command. This example adds the CHECKED element to the INPUT HTML tag. ********************************************************************** Tip of the Day! by Ian Vink If you have a listview control on your webpage, and wish it to resize as the windows resizes, you can add this code to the SCRIPT block in the HEAD section. Sub window_onresize myListView.style.width = document.body.clientWidth myListView.style.height = document.body.clientHeight End Sub ********************************************************************** Tip of the Day! by Kirthan Battapad This tip will show you an easier way to stop and restart IIS. Both these tasks can be performed from the Command Prompt using the Net Command. Create two small command files that stop and restart IIS To stop IIS, run the following command file: StopISS.cmd net stop iisadmin /yes This stops the iisadmin service, which in turn will stop the other Web services. To restart IIS, use this command file: StartIIS.cmd net start iisadmin net start w3svc net start smtpsvc This file restarts the iisadmin, w3svc and smtpsvc services. Each service should be started explicitly because even though stopping iisadmin stops the others, restarting iisadmin will not restart the other services automatically. ********************************************************************** Tip of the Day! by S. Vaidyaraman The Listbox control in ASP.NET can be bound to an array using the code below ' Define an array Dim PopulateArray as new ArrayList ' Populate the array PopulateArray.Add(“Beginner") PopulateArray.Add(“Advanced") ' Specify the array ServerListBox1.DataSource = PopulateArray ' Bind the array ServerListBox1.DataBind A same technique can be used to bind a dataset or collection. ********************************************************************** Tip of the Day! by S Bashkar WebServices can programmatically expose plethora of functionalities. Some of the common uses are quoted below: 1. News Sites such as CNN and BBC can expose the headlines or hotnews as a webservice so that other sites can invoke them and display the latest news. 2. Webservices can be employed for weather forecasts and stock market price watches. If you want to learn more about Webservices, Wrox is releasing Pro ASP.NET Webservices in November 2001. ********************************************************************** Tip of the Day! by S Bashkar Deployment of web applications used to be a severe task in ASP. A traditional ASP Application has to undergo the following at the deployment stage: 1. COM / COM+ Component registration 2. IIS Metabase changes to specify authentication, session states e.t.c 3. Setting the authorisation All of the above time-consuming tasks are totally removed in ASP.NET. Deployment of web applications can be done on the fly with increased efficiency in ASP.NET and it involves just copying the files to the applications directory. For example in order for an assembly to be used in the web application, all we have to do is copy the assembly in \bin directory of the web application. This in itself is a great leap forward for ASP developers. ********************************************************************** Tip of the Day! by Srinivasa Sivakumar Generations are the process used by the garbage collector to improve garbage collection performance. We can find the maximum number of garbage collection generations supported by the .NET Framework by accessing the MaxGeneration property of the System.GC class. <% @Import Namespace="System " %> ********************************************************************** Tip of the Day! by Sandra Gopikrishna MS Access database can be password protected for security reasons. The following ASP snippet guides us through a method of password protecting the access database. 1.Open the database and check the "Exclusive" checkbox in the file dialog box. 2. Click the Tools option of the Menu Bar . In the tools Option of menubar click the Security option and under this, select Set Database Password. Enter the password that needs to be set. 3.Note that the password can be any combination of 14 or fewer characters, other than the control characters, and is case-sensitive ********************************************************************** Tip of the Day! by Ian Vink When your script opens a new window in IE, that new window can control its opening window with the OPENER object of the window object. This example will turn the background color of the MyText text box in the MyForm form to yellow. window.opener.MyForm.MyText.style.backgroundcolor="yellow" ********************************************************************** Tip of the Day! by Sandra Gopikrishna In ASP pages we employ a stylesheet to maintain uniform style across all the pages. The inclusion of style sheets in ASP pages can be done in the following two ways. a. The link tag must be included only in tag of ASP Page b. ********************************************************************** ********************************************************************** Tip of the Day! by Sandra Gopikrishna Server side validation of certain data can be done on the fly by employing regular expressions. Regular expressions cut down the number of statements needed to do complex validations. The following piece of code demonstrates the method of using RegularExpressions on server side to validate the Email address of the user validate.asp ------------ <% Dim myregexp Set myregexp = new RegExp myregexp.pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$" Response.Write myregexp.Test("test@hotmail.com") %> Thus the complex email validation which is supposed to run into lines is cut short into single validataion statement by making using of Regular Expressions. ********************************************************************** Tip of the Day! by Sandra Gopikrishna In ASP in order To access the XML data stored in separate disk files we need to follow the following steps. 1. Instantiate the Microsoft.XMLDOM object by employing the following statement Set myxml = Server.CreateObject("Microsoft.XMLDOM") 2. Set the async property of document object to false myxml.async = false If you set this property to false then DOM will prevent access to the document while it is in process of change or update. 3. Load the XML file myxml.load("file_path") 4. Check for any errors if mydoc.parseError.errorcode<>0 then 'error handling code else ' proceed with accessing the file end if ********************************************************************** Tip of the Day! by Sandra Gopikrishna In ASP When we are generating XML on server side using XML DOM we should inform XML parsers to recognize the XML document. This can be done by employing XML Processing Instruction , which is appended before the root element. The following piece of code describes how to go about using Processing Instruction in ASP <% set objdom = server.createobject("Microsoft.XMLDOM") 'code for creating and appending root element goes here 'create processing instruction and append it before root element Set mypi = objdom.createProcessingInstruction("xml","vertsion='1.0'") objDom.insertBefore mypi, objDom.childNodes(0) 'remaining manipulation goes here %> ********************************************************************** Tip of the Day! by Sandra Gopikrishna Tip #1 ------ In ASP quite often we come across a situation where we have to determine wheather the query returns any records. The following terse snippet shows a method of how to go about finding the wheather the query returns any records. numrecs.asp ----------- <% 'create a connection object and open it set conn = server.createobject("ADODB.CONNECTION') conn.open "dsnname", "username", "password" sql = "select * from table name" Set RS = Conn.Execute(sql) 'check wheather the query returns any records If RS.BOF And RS.EOF Then Response.write "The query returned no records" Else Response.write "The query returned records" 'the logic for looping through the records go here End If 'close the connection and do the garbage collection conn.close set conn = nothing %> ********************************************************************** Tip of the Day! by Sandra Gopikrishna While building Wireless applications employing ASP ,Wireless Markup Language (WML) and WMLScript ,IIS has to be configured so that it have MIME types correspoding to the wireless applications. IIS can be configured to have these mime types by following the steps as explained below A. Open the Internet Information Service snap in from Microsoft management console(MMC) B. Under IIS snapin the machine name hosting the webserver is displayed. Right click on the machine name to get Internet Information Services tab . In this tab under MIME type section click the button EDIT C. Finally enter the Extension and MIME types required for hosting the wireless applications ********************************************************************** Tip of the Day! by Ian Vink When you select a set of nodes, you can have the nodes sorted ASC (+) or DESC(-) by the XSL stylesheet. This example will sort the node "doc" DESC by the value of the element "key". ********************************************************************** Tip of the Day! by Sandra Gopikrishna ASP pages can be made to Output WML content by setting the following Contenttype to the ASP Page as shown below <% Response.contentType = "text/vnd.wap.wml" %> ********************************************************************** Tip of the Day! by Sandra Gopikrishna ASP can be employed to deliver WML Output on request to wap devices. The following piece of code demonstrates this concept by taking a simple example. wmlout.asp ---------- <% Response.contenttype ="text/vnd.wap.wml" %>

Hello WML

When the above asp file is accessed from mobile device or emulator the Message 'Hello WML' is displayed Note : before running the above example the ensure that IIS is having MIME type pertaining to WML ********************************************************************** Tip of the Day! by João Vilaça It's a very comon mistake. Most ASP developers create conections where they are not usefull. For instance: dim rs, con set rs=server.createObject ("ADODB.recordset") set con=server.createObject ("ADODB.Connection") con.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&server.mappath ("filename.mdb")&";" rs.open "SELECT * FROM table", con ... rs.close set rs = Nothing con.close set con = Nothing may become: dim rs set rs=server.createObject ("ADODB.recordset") rs.open "SELECT * FROM table", "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&server.mappath ("filename.mdb")&";" ... rs.close set rs = Nothing ********************************************************************** Tip of the Day! by Sandra Gopikrishna In ASP We come across situations where we need to find out whether some special files such as dll(Dynamic Link Libraray) are available in a given directory. This can be acheived by employing the following two methods of FileSystemObject a. GetSpecialFolder b. FileExists The following asp snippet demonstrates the above concept <% set fso = server.createobject("scripting.FileSystemObject") dllname = fso.buildpath(fso.GetSpecialFolder(1), "mydll.dll") if fso.FileExists(dllname) then Response.write "The mentioned dll exists" else Response.write "The mentioned dll does not exist" end if set fso = nothing %> ********************************************************************** Tip of the Day! by Srinivasa Sivakumar The IL Disassembler (ildasm.exe) allows for the inspecting of all the classes, methods and properties, etc exposed by any managed EXE or DLL. The IL Disassembler tool can be accessed by clicking "Start/Programs/Microsoft .NET Framework SDK/Tools/ IL Disassembler" ********************************************************************** Tip of the Day! by Srinivasa Sivakumar The Finalize method will be called every time the garbage collection processes. Since there is no guaranty time when the garbage collection will occur, our applications can call the "Finalize" method and then tell the GC not the call this method by using the GC.SuppressFinalize Method ********************************************************************** Tip of the Day! by Srinivasa Sivakumar The Finalize method acts as the destructor for the class. Unlike VB's "Class_Teminate" event all the objects will be freed. The "Finalize" method is called when the Garbage collection occurs. Since there is not guaranty that when the garbage collection will occur, our applications can force the garbage collection to occur whenever the application is shutting down by calling the GC.RequestFinalizeOnShutdown Method. ********************************************************************** Tip of the Day! by Ian Vink To have an ASP page called regularly, add a Scheduled Task from your control panel. To do this specify the program as "iexplore http://yourweb/your.asp" ********************************************************************** Tip of the Day! by Sandra Gopikrishna ASP can provide Cache control for WAP Devices. The Following piece of code demonstrates a method of preventing the caching in WAP devices <% Response.contentType = "text/vnd.wap.wml" Response.expires = -1 Response.AddHeader "Pragma", "no-cache" Response.AddHeader "cache-control", "no-cache, must-revalidate" %> ********************************************************************** Tip of the Day! by Srinivasa Sivakumar The tag is used to identify where the client validation script is stored. ********************************************************************** Tip of the Day! by Ian Vink You can use simple VB commands in your XSL conditional commands like the XSL:IF attribute EXPR. Ths exmaple will choose only those elements where the first letter of the text is a "P MS SITE SERVER3.0(Commerce-Edition) comes with 'MSCSadmin.dll' which exposes many useful objects for site. 'AdminService' object from this dll helps to deal with NT Services. The following Code-Snippet gets the information about a service, if it exists and is stopped then it will try to start it. <% Dim objAdminService Dim lStatus On Error Resume Next Set objAdminService =Server.CreateObject("Commerce.AdminService.1") 'Specify the Service Name objAdminService.Service = "ClipSrv" objAdminService.Machine = "" 'specify EMPTY for the local machine. 'Check the existance of the service If objAdminService.Exists Then If Err.number<>0 Then Response.Write "The service specified does not exist on this machine." Response.End Else Response.Write "The service has following properties"&"
" Response.Write "Display Name: "&objAdminService.DisplayName&"
" Response.Write "Path: "&objAdminService.BinaryPath&"
" lStatus =objAdminService.GetStatus Select Case(lStatus) Case 1:Response.Write "Status:Service stopped"&"
" Case 2:Response.Write "Status:service start pending"&"
" Case 3:Response.Write "Status:service stop pending"&"
" Case 4:Response.Write "Status:service running"&"
" Case 5:Response.Write "Status:service continue pending"&"
" Case 6:Response.Write "Status:service pause pending"&"
" Case 7:Response.Write "Status:service paused"&"
" End Select 'Start the service if it is stopped. If lStatus=1 Then objAdminService.Start End If End If End If Set objAdminService =Nothing %> The ASP file which will access the information about the service should be kept under the BASIC authentication, and should be accessed with an NT-USER account who has sufficient previledges to create the 'AdminService' object on the NT-SERVER. AdminService object provides 'pause' and 'stop' methods as well for pausing and stopping the service respectively. ********************************************************************** Tip of the Day! by Sandra Gopikrishna The Connection Object of ADO is provided with OpenSchema Method, using which we can retrieve all the database schema information such as tables, colums, datatypes... The following piece of ASP code demonstrates a method of retrieving all the tables present in a database represented by the dsn. <% const adSchemaTables = 20 set conn = server.createobject('adodb.connection') conn.open 'dsn=YOUR DSN' , 'usid=sa' , 'pwd=' set rs = conn.openschema(adSchemaTables) Response.write 'The database contains the following details :
' while not rs.EOF Response.write rs.fields('TABLE_NAME') & '
' rs.movenext wend %> ********************************************************************** Tip of the Day! by Sandra Gopikrishna If the ASP scripts takes a long time to execute, then an appropriate Message can be displayed on the browser while the asp script is being executed. The message can be displayed by employing a small piece of JavaScript as shown below:

Your Request is being processed Please Wait !!!

********************************************************************** Tip of the Day! by Srinivasa Sivakumar The VB.NET brings shared member concept to the VB.NET classes. What is a shared method? Well, Shared method is been between all instances of the class. If the shared members value is changed in one instance of the class then, the change will reflect in all the instances of the class. Here is an example, <% @Import Namespace="System " %> You’d get the result as; Value of I is: 20, 20 Value of I is: 40, 40 **********************************************************************