C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Mobile Web Application


Posted Date: 11 Apr 2005    Resource Type: Articles    Category: Web Applications

Posted By: Bilal Ahmed       Member Level: Bronze
Rating:     Points: 15



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






Responses

Author: Steve W    15 Nov 2005Member 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 2007Member 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 2007Member 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 2008Member Level: Bronze   Points : 1
This is fare enough but need some more information like how to run this code exactly.........


Author: saravanan    16 Sep 2008Member 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


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Mobile Web Application  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: A generic loading of Data in a DropdownList using DataAccessLayer & caching mechanism
Previous Resource: How to highlight a row in datalist when an user click on that row
Return to Discussion Resource Index
Post New Resource
Category: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

efax

Contact Us    Privacy Policy    Terms Of Use