I have seen many people asking questions in forums about Mobile web application development using ASP.NET WebForms. So i planned to write a blog post on the same.
ASP.NET is a powerful web application development platform, allows to leverage most of the features in Mobile web application development. Now a days, mobile devices are capable of rendering HTML 5 content. Websites which works in desktop browser is rendering great in mobile browsers too. Mobile web browsing is rapidly increased and every one looking for ON THE GO solution!
Now, the question is, Can we convert the existing web application to Mobile web application?
Answer is YES. You can can do that. Just by adding the Viewport meta tag to the Head section of the webpage and you are done!
- <meta name="viewport" content="width=device-width" />
To know more about the Viewport meta tag, check this link – Viewport. This viewport meta tag works absolutely fine in all major mobile device browsers including –
- Apple iPhone – Mobile Safari
- Android(GingerBread, ICS, Jelly Bean) – Native browser, Google Chrome, Opera
- WindowsPhone – IE9 and IE 10
- BlackBerry – Native Browser
Sample Code –
- <%@ Page Language="C#"
- AutoEventWireup="true"
- CodeBehind="Index.aspx.cs"
- Inherits="MobileApp_WebForms.Index" %>
- <!DOCTYPE html>
- <html>
- <head runat="server">
- <title>Mobile WebForms</title>
- <meta charset="urf-8" />
- <meta name="viewport" content="width=device-width" />
- <style type="text/css">
- body
- {
- font-family:Verdana;
- }
- label
- {
- width:100px;
- float:left;
- display:block;
- }
- input[type=text]
- {
- width:200px;
- }
- .content
- {
- width:350px;
- margin:0px auto;
- }
- header
- {
- width:350px;
- text-align:center;
- font-size:15px;
- font-weight:bold;
- }
- .button
- {
- width:350px;
- text-align:center;
- }
- </style>
- </head>
- <body>
- <form id="form1" runat="server">
- <div class="content">
- <header>
- Contact Us
- </header>
- <div>
- <label>Name</label>
- <asp:TextBox runat="server" ID="txtbox" />
- </div>
- <div>
- <label>Email</label>
- <asp:TextBox runat="server" ID="txtEmail" />
- </div>
- <div>
- <label>Phone</label>
- <asp:TextBox runat="server" ID="txtPhone" />
- </div>
- <div class="button">
- <asp:Button Text="Send" runat="server" />
- </div>
- </div>
- </form>
- </body>
- </html>
Try the above code in a mobile browser and you will find the difference!
Next question is, How do we create a separate version of Mobile web application?
We can create stunning mobile specific web application using ASP.NET WebForms and when you access the web application from desktop browser it renders the general desktop web app and when you access it from Mobile browser it renders the mobile web app.
How we need to redirect the user to the respective web app, when user access from different devices?
I explained the same in one of my earlier blog post – Detect the device and redirect in ASP.NET. That’s one way of doing it. We have few more ways to do the same.
- JavaScript – By sniffing the UserAgent string and redirect to the appropriate web app – DetectMobileBrowsers
- CSS 3 Media Queries – Take advantage of CSS 3 media queries and you can redirect the users based on the requested device – MediaQueries. I feel it’s more elegant way.
It’s up to you to choose the right method, based on the devices you are going to support!
I also suggest you to check the following JavaScript Framework, which has great API support for mobile web application development.
There are many mobile frameworks available, but the above mentioned are good and have great API’s to quickly design a mobile web application.
Now comes the final part, Testing. Testing the mobile web application is real challenge. Everyone can’t afford to buy physical devices and test the web applications. Few device manufacturers provide Emulators, so that we use to test your web application.
Check the below links, which i have blogged earlier related to testing the web application on Emulators!
So, not least, ASP.NET Mobile website – Mobile. Great repository of information related to developing mobile web applications in ASP.NET and links to some cool tutorials.
If you have any queries or doubts in developing Mobile web applications, do post your questions in Mobile and Handheld Devices Section in ASP.NET Forums. All time experts, great answers!
Happy mobile web programming!!!
Thanks!
Thank you for the auspicious writeup. It in fact was a amusement account it.
Look advanced to more added agreeable from you! However, how
could we communicate?
Great goods from you, man. I have understand your stuff previous to and you’re just too excellent. I actually like what you have acquired here, certainly like what you are stating and the way in which you say it. You make it entertaining and you still take care of to keep it sensible. I can’t wait to read much more from you.
This is actually a terrific web site.
Great Article. A question here. Does the mobile asp.net webform displays all the asp.net controls on mobile devices exactly. Also there are different ajax control kit controls, so is that all displays exactly as in desktop browser?
Hi Vishnu,
Glad you liked the article! Yeah, all the ASP.NET controls works fine in Mobile browsers. Not true with AJAX Control ToolKit! Instead you can try using jQueryMobile Controls, which is more elegant!
Hope it helps u…
Also please help me to know about silverlight controls, wheather, is there any ways to create a silverlight mobile web application?
Silverlight controls doesn’t work with Mobile browsers! Infact Apple iPhone, Android and BlackBerry doesn’t support Silverlight! May be WindowsPhone supports!
Hope it helps u…
I all the time emailed this web site post page to all my contacts, for the reason that if like to read it afterward my friends will too.|
I feel that is a genuine good website.Actually thanks! Want far more.
I just want to tell you that I am just newbie to weblog and truly enjoyed this web-site. More than likely I’m going to bookmark your blog post . You amazingly come with fabulous writings. Appreciate it for revealing your web page.
Thanks for your time for writing “Mobile Web Applications with ASP.
NET WebForms | Roopesh Reddy’s space” http://celebrationofcourageevent.org . I reallywill certainly end up being back again for more browsing and writing comments in the near future. Many thanks, Tyler
“Mobile Web Applications with ASP.NET WebForms | Roopesh Reddy’s space” Window Treatments For Large Windows was indeed a fantastic post, can’t wait to look at far more of your blog posts. Time to spend several time on-line lmao. Thank you -Marshall
My mobile application is working fine in my desktop but it is not loading correctly iphone simulator(Electronic mobile simulator)
My code is:
.auto-style1 {
font-family: Arial, Helvetica, sans-serif;
}
.auto-style2 {
font-family: Arial, Helvetica, sans-serif;
font-weight: normal;
}
.auto-style4 {
color: #0000FF;
font-weight: bold;
}
Travel Request – Pending / Action Taken
Request ID
Request Type
Request status
Employee Details———————————————————————————————————————————————————————————————————
Employee ID
Short ID
Name
Grade
Vertical
Vertical head
L1 Manager
L2 Manager
Cost Center
Location
Travel Details—————————————————————————————————————————————————————————————————————-
Trip Category
Purpose of Trip
Travel Type
City From
City To
Travel Date
Preferred Time
Accomodation Required
Travel Mode
Agra
Chennai
06-Aug-2011
-
Required
Train
Bhuj
Calicut
05-Aug-2011
-
Required
Air
Financial Details ———————————————————————————————————————————————————————————————————-
Billing Status
Cost Centre
Amount Needed as Advance
Date Advance Needed
Approval / Remarks
——————————————————————————————————————————————————————————————————
L1 Approver
Other Details and Comments —————————————————————————————————————————————————————————————
Comments
Action Log ——————————————————————————————————————————————————————————————————————–
Date and Time
Action By
Action
Remarks
25-Jul-2011 01:31 PM
Amar Goyal
Save As Draft
-
25-Jul-2011 01:32 PM
Amar Goyal
Submitted By Requestor
-
and i have used the tag in mobile.master. Still it is not showing full page in mobile it is showing only part of the page.
Please help me I am new to mobile development. I am unable paste my simulator output.
Is it necessary to use mobile form and mobile controls to develop mobile application…Because in web forms we dont have such controls.I am devleoping mobile application using web forms.
Hi Hema,
Mobile web forms controls are not necessary to develop Mobile web applications. Normal ASP.NET controls works absolutely fine in Mobile browsers too. Did you tried adding the Viewport META tag to your page? If not, add it and try again! Moreover, if you have any demo page, we can take a look at it.
Hope it helps u…
yah i have used that viewport tag in my master page but still when I tried my application in emulator view is differnet…I am unable to paste my screen shots and code here…Could you please tell me where I can send that info
Mailed you my code and my output of emulator and normal desktop output to this mail id:
cr.reddy@hotmail.com … Please help me.
Yeah! I will check it.