| Jerry Dausman's profileThere's an answer to you...BlogLists | Help |
|
|
September 28 Sharing Session between ASP and ASP.NETOne of my students in my recent Upgrading to ASP.NET class wanted to know how to share Application and Session variables between .asp and .aspx pages. The manual says you can't do it directly. Two minutes after the last student left I found good answers from Microsoft MVP Peter A. Bromberg's site.
There are two ways you can share the information. We discussed one of the ways in class: create a COM object that you use in place of a session object. When you save a session variable you would use both the session id (which you can retrieve from ServerVariables) and a key to store the value. Since you can use COM objects in both .asp and .aspx pages, each would have access to the information. The COM object would typically use a database to store the data on the back end. The second way the MVP suggested was to store the data in both Session variables and hidden <input> tags, posting them across from .asp to .aspx, and vice versa.
A detailed discussion and accompanying code can be found at http://www.eggheadcafe.com/articles/20021207.asp and
August 07 Easy XML MenuThe one thing in the MS2310 class that bothers me the most is the clunky menu system they have you do as a web control. I understand why they have you do it as a class: to demonstrate class building and usage. But that's not how we'd do it in real life, is it? I prefer doing my menus in XML files. It makes them easy to update on the web. The following code shows one way to use an XML file in a menu control.
First we need an XML file that describes our menu. The following example file is one way of structuring an XML file to be a menu file:
The easiest way to translate this xml into something visible is to use an xslt stylesheet. The following is a simple stylesheet:
Now, if we call the XML menu file Menu.xml and the XSLT stylesheet file Menu.xsl we can simply put an XML Data Control on a user-defined web control page (an .ascx page) like so:
Voila! We have a menu control we can drag-and-drop on any individual .aspx page (or our MasterPage). Now changing a menu is as simple as changing our XML data file.
If you're looking for a bit more control, check out my next blog article (Coming Soon!) and I'll show a more involved alternative that still uses an XML file for the basic menu.
July 21 Demo WebService FunctionalityOne of the (almost) unavoidable aspects of using the demo webservices in the official Microsoft courseware is that they all run on the instructor's computer. In other words, they are on the local LAN. One of the great benefits of webservices (in my humble opinion) is that the functionality can be anywhere on the internet. So, to demonstrate that benefit in my classes, I use a webservice on my personal website. I have just rewritten my webservice to include two functions, accessable by the HTTP Post and Get protocols: .Punchline and .CrazyWords. .Punchline takes no input parameters, .CrazyWords takes 8 strings as input.
Here is the URL: http://www.Dausman.net/Functions.asmx . Have fun!
March 01 Web Service Protocol ConfigurationWe all know that the .NET Framework 1.1 disables by default the web service protocols HttpGet and Http Post. If you don't know how to turn them back on again ... read on!
The key is adjusting your web.config file. You need to add a section, under <system.web> called <webServices>. Inside the <webServices> element you add the <protocols> element. The <protocols> element allows three sub-elements: <add>, <remove>, and <clear>. <add> allows the web service to use the protocols not normally initialized. The code below shows you how to implement HttpGet and HttpPost in your web.config file.
<configuration>
<system.web> <webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices> </system.web> </configuration> The <remove> element is used the same way, but to turn off protocols, such as HttpSoap.
<configuration>
<system.web> <webServices> <protocols> <remove name="HttpSoap"/> <remove name="Documentation"/>
</protocols> <webServices> </system.web> </configuration> The <clear> element removes all protocols from your web service.
You may have noticed I removed a protocol called 'Documentation'. Removing Documentation turns off both the Help Page automatically generated by the web service, and generation of the WSDL file. If you don't want a help page, but do want a WSDL file you can redirect WSDL generation to a file of your choice. The code below demonstrates this.
<webServices>
<wsdlHelpGenerator href="docs/MyWSDL.htm"/> </webServices> Of course, you may choose to display only the portions of the actual WSDL file that you want the public to use. References used for this blog posting are: for protocols, and http://msdn2.microsoft.com/en-us/library/2tyf2t8t.aspx for the Documentation protocol.
October 11 Alternative to UDDII find that the promise of UDDI and the actual reality are too far apart for me as yet. How do I find web services on the internet? One of two ways ...
First way: If I'm looking for specific information I go to the company's site that would have that information. For instance, if I want information on books, I search Amazon.com to see if they have "programmer tools", "API's" or similar pages. Lo and behold, they do! (I'm registered as a developer on Amazon, so I can use their web services to search or place orders.) You can also search companies like FedEx, UPS and the US Postal Service, i.e., organizations who want to computerize their interactions with consumers to speed up service. All those folks have web services.
Second way: go to a web site that lists web services in a typically "web page" fashion. One of my students clued me in to www.WebServiceX.net/WS/default.aspx. A check of that site's links led me to www.WebServicesMall.com. I used to use my own web service's functionality in my in-class demos ... but it's kind of lame. Check the above ones out!
July 09 Validators made more 'User Friendly'If you've ever used a validator before, then you know that they will let you place an error message and text on the web page whenever a user has a problem. If you take a look at the html code in the source .aspx document you will see this familiar tag:
(I've shortened the code by leaving out some of the other attributes you may want to use.)
To me, the interesting thing about validators is where they tend to put the text attribute values: between the start and end validator tags (as shown in red above). Ever try putting something there besides text? You can actually load this area with table tags, images, html buttons, and lots of other things. Those things, like pictures, might be useful to an unskilled user that doesn't know what to do.
|
|
|