HOME

.NET Mobile
Mobile HOME
Mobile Intro
Mobile Example
Mobile Emulators
Mobile Forms
Mobile Events
Mobile Input
Mobile Validation
Mobile Lists
Mobile Selection
Mobile Images
Mobile Utilities

References
Mobile Reference
Mobile Devices
Mobile Update 1

Please visit our sponsors !

.NET Mobile Example

previous next

The Mobile ASP.NET Page

Mobile Controls are the main building blocks of mobile applications.

Mobile Controls are similar to Web Controls in ASP.NET.

If you are not familiar with ASP.NET development, you should leave this tutorial and study our ASP.NET tutorial first.

This ASP.NET page displays “Hello W3Schools” as an WML card in an WML enabled cell phone:

<%@ Page
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register
TagPrefix="Mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<Mobile:Form runat="server">
   <Mobile:Label runat="server">Hello W3Schools
   </Mobile:Label>
</Mobile:Form>

The Page directive tells ASP to use (inherit) mobile page handling instead of regular page handling (like the one used for traditional browsers)

The Register directive defines the prefix that will be used for mobile controls. We have used "Mobile",  but you can use any prefix you like.

The <Mobile:Form> element tells the server to create a mobile form control.

The <Mobile:Label> element tells the server to create a mobile label control with the text “Hello W3Schools”.


The Mobile ASP.NET Output

When the ASP page executes, it will produce this output to a WAP enabled mobile phone:

<?xml version='1.0'?>
<!DOCTYPE wml PUBLIC 
'-//WAPFORUM//DTD WML 1.1//EN'
'http://www.wapforum.org/DTD/wml_1.1.xml'>

<wml>

<card>
<p>Hello W3Schools</p>
</card>
</wml>

While this output will be produced for a Pocket PC:

<html>
<body>
<form id="ctrl1" name="ctrl1" method="post"
action="example.aspx">
<div>Hello W3Schools</div>
</form>
</body>
</html>


Conclusion

.NET Mobile will generate WML code for cell WAP enabled cell phones and HTML code for devices like the Pocket PC.

By detecting the browser, .NET Mobile will output correct content, providing developers with a powerful tool to develop single applications that will serve many different mobile devices.


previous next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

IISProtect
Password Protect
Your Web Pages



Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search