Posts

Showing posts from December, 2006

Leveraging Client-Side Enhancements in ASP.NET 2.0

ASP.NET 2.0 offers some interesting client-side enhancements that provide a higher-level abstraction to common web development chores so that developers don't have to dirty their hands with the intricacies of HTML & JavaScript. Scott Mitchell shares these 3 tips in a 4Guys.. article . 1) To maintain scroll position on postbacks, the MaintainScrollPositionOnPostback Page directive can be set to "true". To apply it to all pages in the website, it can be added to the pages element within the <system.web> element in web.config. 2) To programmatically set focus to a Web control on page load, the Focus() method (available for all Web controls in ASP.NET 2.0 including the TextBox Web control) can be used. Javascript for the ASP.Net 2.0 controls is typically generated by a request to webresource.axd . WebResource.axd is a new built-in HTTP handler in ASP.NET 2.0 that's used to retrieve script code into pages . 3) To perform a client-side action when a Button, Li

HOW TO display ANY "flat XML" file as a HTML table using generic XSL stylesheet

Image
In response to a forum posting, I adapted the XSL code in the article "Convert XML To an Excel Spreadsheet Using XSL" to display ANY "flat XML" file (like the one used in the examples in W3Schools) as a HTML table with this generic XSL stylesheet - <?xml version= "1.0" encoding= "ISO-8859-1" ?> <xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" > <xsl:template match= "/" > <HTML> <BODY> <xsl:apply-templates/> </BODY> </HTML> </xsl:template> <xsl:template match= "/*" > <TABLE BORDER= "1" > <TR> <xsl: for -each select= "*[position() = 1]/*" > <TD> <xsl:value-of select= "local-name()" / > </TD> </xsl: for -each> </TR> <xsl:apply-templates/> </TABLE> </xsl:template> <xsl:te

HOW TO auto fill State and Country based on City using Javascript

The quick & dirty Javascript code below is based on the idea by Jason Hunt that makes use of Yahoo! Maps Web Services - Geocoding API It works only in IE 5 or higher (untested in IE 7). The Geocoding Web Service is actually meant to find the specific latitude and longitude for an address but we shall use the state and country that it also returns. If there are multiple cities with the same name, the first set of values returned by the web service are considered. <HTML> <HEAD> <TITLE> Auto fill State and Country based on City </TITLE> <SCRIPT LANGUAGE= "JavaScript" > function getStateCountry() { var sUrl = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=YahooDemo" ; sUrl += "&city=" + crmForm.address1_city.value; var oXmlHTTP = new ActiveXObject( "Msxml2.XMLHTTP" ); oXmlHTTP.Open( "GET" , sUrl, false ); oXmlHTTP.Send(); var oXmlDoc = oXmlHTTP.responseXML; crmForm.address1_stateorprov