荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: Jobs (温少), 信区: Visual
标  题:  ASP+ Mobile Controls
发信站: BBS 荔园晨风站 (Sun Sep 17 04:03:30 2000), 转信



         ASP+ Mobile Controls

    If all the media news and hype is to be believed, we'll all be using
a cellular phone or other mobile device to access the Web in the near
future. OK, this may be a little over optimistic, but there's no doubt
that the number of visitors to your Web site that are not using a
traditional PC朾ased browser will continue to increase. To make coping
with the various types of mobile devices easier, in particular cellular
phones, ASP+ boasts a selection of server controls that provide output
in WML rather than HTML. In this article, we look at the controls that
Microsoft is currently developing. This article will also look at some
of the issues involved in detecting the type of user-agent, and serving
appropriate content ?whether it's a mobile device, TV set-top box, or
even a refrigerator.

The Lead-up to ASP+
Various ways exist for creating dynamic Web pages. In the past, the
predominant technique was the use of executable programs that accessed
the Web server via the Common Gateway Interface (CGI). However, over the
past few years, new techniques that allow script code to be used within
HTML pages have become more popular. Amongst these techniques are Perl,
Java Server Pages (JSP), and Microsoft's Active Server Pages (ASP).


    ASP started life as just a DLL that accessed the Web server through
the Internet Server Application Programming Interface (ISAPI) ?in other
words an ISAPI DLL. This interface provides a fast and reliable
connection to the Web server, as (unlike CGI executables) the code runs
within the same process or memory space as the Web server. Using this
technique, ASP has evolved to become the version 3.0 that is installed
as part of Windows 2000.


Enter .NET
The fundamental design of ASP is now changing, along with the
introduction of the new Microsoft .NET Framework. This framework is a
complete departure from the language and operating system杝pecific
structure of existing programming environments.

Today, most programming languages compile the source code directly to
native code (code that runs directly on the processor), and hence are
dependent upon the processor type. For example, code compiled for an
Intel processor will not run on a Motorola processor.

The one major exception to this is Java, which uses a separate virtual
machine to execute code that is compiled to a special processor and
operating system杋ndependent format. As long as a suitable Java virtual
machine exists on the target system, the code can execute.

Microsoft has taken a broadly similar, but far more wide杛anging
approach with the new .NET Framework. This provides a complete
development and runtime environment within which code can execute. This
code is compiled into a special Intermediate Language (IL). All of the
source code compilers create IL code ?in theory the same code
irrespective of the source language. This code is usually referred to as
managed code.

So, code written in Visual Basic, Visual C++, JScript or the new
language C#, will all be complied to the same IL code. And these
compilers are included as part of the .NET Framework. The Framework then
looks after all aspects of executing the IL code ?from compiling it to
the final binary format for the respective processor, caching the IL and
compiled code and then managing execution, to providing system services
such as garbage collection, component activation and management, and
error handling and reporting.



The ASP+ Framework

By combining the techniques of ASP with the .Net Framework, Microsoft
has created a development system that provides a far better way of
developing dynamic Web pages, along with a runtime environment that
offers huge increases in both performance and scalability. This is
called Active Server Pages+, or just ASP+.


How Does ASP+ Work?
The major new feature in ASP+ is the 'postback' architecture combined
with the new application and page event models. ASP+ is part of the new
managed code environment. This means that new techniques for reacting to
events, such as a page loading or an application starting, can have code
linked to them.

Often more useful, however, is the way that the postback architecture
within each page works. Effectively this involves an HTML <FORM> and
HTML controls elements, but executed on the server within the ASP+
environment. This seemingly strange concept allows ASP+ to output
content to the browser or client that not only creates the required HTML
page, but also adds to it the extra 'stuff' required to maintain values
in each of the controls and pass them back (that is, POST them back) to
the server.

And, because ASP+ controls the way that the page behaves though the
extra HTML code, and attributes that it adds to the page, it can also do
more fancy things. As the page is being created on the server, the ASP+
engine can detect how the form was submitted ?that is, which buttos such as a
click on a SUBMIT button or the selection of a value in
a list. In effect, the procedural model of earlier versions of ASP has
been replaced by the event杁riven programming concepts of modern GUI朾
ased applications.

The special 'HTML elements' required as foundations for the new postback
architecture are known as ASP+ Server Controls, and a comprehensive set
of these controls is included with the standard ASP+ installation. You
can also create your own controls, or inherit from and extend existing
ones ?using Visual Basic or any other of the .NET supported languages.


What are the ASP+ Mobile Controls?
One of the issues causing much concern to Web developers at the moment
is the rapid growth of the 'mobile device' market. Literally hundreds of
different types of device are appearing, none of which really match the
physical or display characteristics of the ubiquitous PC朾ased Web
browser. This range encompasses, but is not limited to, 'wireless
devices'. As well as cellular phones an prototype
set of Mobile Controls that can vary their output based on the
requesting device type. If it's a cellular phone that expects pages
coded in WML (Wireless Markup Language), then that's what the control
will create. If it's Microsoft Mobile Explorer on a PocketPC that
expects HTML, then the control will oblige with this format.


However, the point is that the controls are intelligent enough to be
able to create output that offers the same (or as similar as possible)
functionality irrespectithat device type. Instead, you just
use the controls and leave it to them to figure out what to output to
that client.


What do the ASP+ Mobile Controls do?
So, we know that the Mobile Controls are designed to create output that
is dependent only on the device type and its capabilities and
characteristics, while shielding the designed Web page or the programmer
from this complexity. But what can the controls actually do, and how do
you use them?

The Mobile Controls Range
The controls that are available in the current prototype release are:


MobilePage ?represents the 'deck' in WML terms
Panel ?represents a 'card' in WML terms
Form ?holds the user杋nput controls
Label ?creates text in the page
Command ?creates a link or command in the page
TextBthe sample config.web file must be added to the application
directory, or at least the <browsercaps> section of it copied into an
existing config.web file. It's through the BrowserCapabilities control
(an integral part of ASP+) that the mobile controls figure out what
language and format to create for return to the client.


At present, the prototype versions of the Mobile Controls only output
either WML for cellular phones or HTML for PocketPC devices and other
clients. However, the range of available formats will include things
like XHTML, HDML, cHTML, and others in the future.

Using the Mobile Controls
Using the Mobile Controls is just as easy as using any of the other ASP+
Server Controls ?in fact it's easier because they will generally create
t" />
    <Mobile:Command runat="server" id="Button" Label="OK"
            TargetType="FormAccept" OnClick="Button_OnClick" />
  </Mobile:Form>
</Mobile:Panel>

Note: In the present release, every Panel control has to have a
Mobile:Form control that encloses the entire content. This requirement
will disappear in future releases.

The result of this is a page or panel that contains a label, a text
input area, and a command link. When viewed in a normal browser it looks
like this:



However, when viewed in its intended target device (here demonstrated by
the Nokia cellular phone emulator), it looks like this:



We're simply going to display a Welcome message containing the user's
name, and so we add a card to the existing deck by placing another
PanelcomeMessage.Text = "Welcome '" & NameEdit.Text & "'"
    SetCurrentPanel (pnlTwo)
  End Sub
</script>

This works because the first card (or panel) contains a Command control
that specifies the name of our Visual Basic subroutine that runs when
the command is carried out:

<Mobile:Command runat="server" id="Button" Label="OK"
  TargetType="FormAccept" OnClick="Button_OnClick" />

The code in the subroutine just has to collect the user's name from the
Textbox control in the first panel and assign the res second panel to the user:

SetCurrentPanel (pnlTwo)

The result in a normal browser looks like this:



And in the Nokia phone emulator, it looks like this:



Summary
While ASP+ is still a new and evolving technology, and in many ways a
complete change from the techniques of programming in ASP 3.0 and
earlier, it is already clear that the advantages it provides will make
it very popular. By building upon a universal runtime that can execute
on all types of Windows machines, from Windows 2000 Server to Windows
CE, Microsoft have provided a platform that makes it far easier to
develop applications that have to work with various disparate types of
client device. The ASP+ Mobile Controls automatically detect the client
type through entries added to thet device).



--


   我想超越这平凡的生活,注定我暂时漂泊!

   我无法停止我内心的狂热,对未来的执着!

※ 来源:·BBS 荔园晨风站 bbs.szu.edu.cn·[FROM: 192.168.18.211]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店