Mobile Web Application
Mobile devices are everywhere, these days everyone is connected with the world using wireless devices and amazingly mobiles are most commonly used wireless device. Due to enhancement of its technology, today most of the mobile devices can get connected to the internet and access the web pages. As a programmer we have to take advantage of this new territory.
Asp.net provides a mobile component which allows you to build applications for mobile devices to access web pages. Creating a mobile application is just simple as like ASP.Net application.
What is mobile web form?
The way you write program for the mobile application is same as ASP.Net, same procedure, even the file extension also as .aspx. But the real fact of mobile form is its server control, which is designed in a special way for mobile devices and it automatically adapt themselves compatible to the type of mobile devices. Once a version of mobile form is built, then it can be accessible from Nokia cell phone and up to pocket PC.
What we need to run Mobile Web forms
1. Windows 2000 or above with IIS 5.0 Installed 2. .NET Framework SDK 3. Mobile Web SDK – which can be downloaded from http://www.wirelessdevnet.com/channels/wap/features/mobilesdk6.html 4. Finally we need an emulator to run the mobile application.
You may think as I think before, what is emulator? Some of us don’t have a mobile device to test the application, hence emulator can be used. It displays the output as such as mobile display. Microsoft Mobile Explorer is one of the emulators and this can be downloaded freely from Microsoft website http://www.devhood.com/tools/tool_details.aspx?tool_id=52 .
Take a break, install all the pre-requisites and then have a look on the following program, which get an input from a user using mobile web form and then displays a welcome message.
<html><body> <%@ page inherits="System.Web.UI.MobileControls.MobilePage" Language="VB" %> <%@ Register TagPrefix="Mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
<script runat="server" language="vb"> Private Sub cmddisp_click(obj as object,e as eventargs) lblmsg.text="Welcome " & txtname.text &" You are using Mobile Web form using .Net" End sub </script> <body>
<mobile:Form id="Form1" Runat="server"> <mobile:Label id="Label1" Runat="server">Enter Your Good Name</mobile:Label> <mobile:TextBox id="txtname" Runat="server"></mobile:TextBox>
<mobile:Command id="cmddisp" onclick="cmddisp_click" Runat="server">Press Me</mobile:Command> <mobile:Label id="lblmsg" Runat="server"></mobile:Label> </mobile:Form> </body>
</html>
Understanding Concept
<%@ page inherits="System.Web.UI.MobileControls.MobilePage" Language="VB" %> <%@ Register TagPrefix="Mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
The above code is necessary to run the application , I will explain about this in the next session
Just start looking from mobile:Form, it tell the server that mobile form components are starting from here, ID property specifies the name of the form which I mentioned as FORM1 and if you skipout the RUNAT property then any mobile control will not work, instead it will show the error
Every mobile component should start with <mobile:componentname properties > and close with </mobile:component>
ID – property specifies the user defined name for the component, which will be useful for using the component in our program.
<mobile:Label id="Label1" Runat="server">Enter Your Good Name</mobile:Label> <mobile:Command id="cmddisp" OnClick="cmddisp_click" Runat="server">Press Me</mobile:Command>
Look at the above codes the caption for both label and button component is in between of the tags and it can be changed using COMPONENTNAME .Text property
OnClick="cmddisp_click", this property will call the click event of the button. And the procedure for the click event is defined between <script></script< tag.
Script tag also has property , where to run the script whether server side or client side, also It has an language property on to which language we are scripting. There are programmer who are familiar with jscript, vbscript, vb, c# and so on. They can use this language property for their convenience.
Summary The entire target of the above program is to get a name from a user and process with a script and display the welcome message. This is code is test using Microsoft Mobile Explorer. In the next series articles you will able to learn the other components, data driven programming for mobile application.
Hope everything is clear with this article for any comments; don’t hesitate to send mail tm.bilal@gmail.com
|
| Author: Steve W 15 Nov 2005 | Member Level: Bronze Points : 0 |
The article is helpful for providing a "helicopter view" of the subject but the English is of a poor standard and would benefit greatly from review by an editor/proofreader.
|
| Author: urpalshu 10 Oct 2007 | Member Level: Gold Points : 0 |
It was great reading your article at http://www.dotnetspider.com/kb/Article1224.aspx
Question?
Finally as you say we need an emulator to run the mobile application.
I have a DeviceEmulator.exe
I created an ASP.NET with Mobile Web Forms.
When I run the Application, it works just perfect on Internet Explorer.
How Do I run the ASP.NET Application on an Emulator?
I have Visual Studio 2005 Installed
Thank you,
|
| Author: venkata koti reddy 12 Nov 2007 | Member Level: Gold Points : 0 |
This is ggod,but better to give how open the mobile form i.e give the procedure to open the .net mobile form (Ex:-start-->programs-->like this)
|
| Author: Shiva 22 Aug 2008 | Member Level: Bronze Points : 1 |
This is fare enough but need some more information like how to run this code exactly.........
|
| Author: saravanan 16 Sep 2008 | Member Level: Gold Points : 2 |
Hi..
Can you give some sample code for developing the mobile application. Because I already developed a Poker game using flash. Now I want to do the same in Windows Mobile. Herewith i have given my code for your ref. what changes I would made. Because I got win32 exception error.
try { //SAConnection conn = new SAConnection("DBF=\\Program Files\\SimpleSA\\SIMPLESA.DB;UID=DBA;PWD=sql"); // Data Source ="D:\testappsec\test\test\db.sdf"; objcon = new SqlCeConnection("Data Source =\\My Documents\\db.sdf"); //objcon = new SqlCeConnection("Data Source =./MyDatabase#1.sdf"); objcon.Open(); cmd.CommandText = "Insert into Name(ID,Name,Place) values('236','sarav','nag')"; cmd.Connection = objcon; cmd.ExecuteNonQuery(); objcon.Close(); Process p = new Process(); p.StartInfo.FileName = "\\My Documents\\2396.exe"; p.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message); }
Plz help me............. Its very urgent...
Thanks, Sarav
|