w3schools
  
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About

.NET Mobile Example

« Previous Next Chapter »

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.

The following ASP.NET page displays "Hello W3Schools" as a WML card in a WML enabled cell phone:

<%@ Page
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register
TagPrefix="mob"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>

<mob:Form runat="server">
  <mob:Label runat="server">Hello W3Schools</mob:Label>
</mob: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 "mob",  but you can use any prefix you like.

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

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

When the ASP .NET page executes, it will produce the following 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>

and 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 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 Chapter »


1,050,724 Sites built with Wix. Make your own!

Click here to design a Stunning Flash Website for Free

Wix is a revolutionary web design tool that provides anyone with the possibility to create professional and beautiful websites for free.

With e-commerce features, search engine visibility and many more professional tools, Wix is the ultimate solution for creating a spectacular site while saving tons of money.


WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting
Top Web Hosting
Windows Hosting
WEB BUILDING
Download XML Editor
FREE Flash Website
FREE Web Templates
FLIGHT TICKETS
Find the cheapest flight
to any destination now!
EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification
STATISTICS
Browser Statistics
Browser OS
Browser Display