Creating web application for mobile devices in asp.net

You can then copy the ProductManager. Using an MVVM approach to development provides for a nice separation of concerns in your applications. The ProductViewModel class is shown in the following code snippet. Change the name to ProductController and click the OK button. Write the following code in the Index method. This method creates an instance of the ProductViewModel class and calls the LoadProducts method to build the Products property in the view model.

Set the name to Index and click the OK button. Write the code shown in Listing 2. You use Bootstrap table classes to help with styling the table. You loop through the collection of product data in the Products property of the ProductViewModel class. You should be able to run the application at this point and see your table of product data appear.


  • temple run 2 apk free download for android!
  • samsung galaxy a3 screen protectors.
  • free pandora radio app for iphone.
  • Subscribe to RSS;

Before you continue with this article, please copy the contents of your CSHTML page into notepad, or save it to another file. Re-run the application and look at the result. You should now see more of the table, but the data is now wrapped within the columns.

Mobile Development Options for .NET Developers

If you have several more columns, it also forces the user to scroll left and right to see all of the data. If you reduce your table to two columns, you find that it fits on a small device screen just fine See Figure 3 and Figure 4. Leave the delete button in the last column, but take the code that displays the Introduction Date, Price, and URL columns and put them into the first column, as shown in the following code snippet:.

Instead of using an HTML table, you might display a list of Bootstrap panel controls that contain your product data. In the sample shown in Figure 5 , you see the same data, but the most important data, the product name, is displayed in the panel header area. The other information about the product is displayed within the body of the panel. The actions you can take are displayed within the panel footer area. As you can see, this list of data looks just as good on a normal desktop browser Figure 5 as on a mobile browser Figure 6.

Figure 6: The Bootstrap panel classes look very good on a mobile device. After typing in the code snippet, run this page to see a Bootstrap panel. Add the actions for Edit and Delete by using Bootstrap glyphicons within the footer of the panel. Notice the use of the two glyphs for the actions that the user can take. It can sometimes be hard to click on a hyperlink with your finger on a mobile device. They can also be hard to see on a mobile device. I find using large buttons with a graphic gives the user a nice big target to hit with a finger.

A Little More Involved

Fill in the body of the panel with the rest of the product data. The code in Listing 3 uses Bootstrap row and column classes to display the appropriate product data within the Bootstrap body of the panel. The column width is modified depending on the size of the browser. As soon as a mobile device is detected, the col-xs-4 class is used for the first column and col-xs-8 for the second. If you look at the Introduction Date field, you also notice that the words used in the label change depending on the size of the browser. This is one of the great things about using Bootstrap: the ability to hide and display things using simple CSS classes.

However, sometimes, your users insist on seeing tabular data. When browsing on a desktop browser, you can have a page that looks like Figure 1 , but when viewing on a mobile device you can have the page that looks like Figure 6. This value is going to be set by the device detection code you write.

This property helps your Index. Create two. At the top of each of these partial pages, add the following line of code.

how to create a mobile website | The phon-er.com Forums

Create the partial page for the desktop browser by getting the Razor code you saved earlier with the original HTML table. Now modify the Index. Run your application in your desktop browser and ensure that you see the full HTML table. Next, stop your application and set the IsMobileDevice property to a true value. Re-run the application and ensure that you see the Bootstrap panel. There are many methods to detect what kind of browser is running the method in your controller, ranging from very simple to very complex.

You can even purchase a subscription to a service for device detection. Create a controller base class from which all your controllers can inherit. Open the ProductController. This method looks at a couple of properties of the Request object to determine whether the browser running the code is a mobile browser. Listing 4 contains the complete code for the IsMobileDevice method. The IsMobileDevice method looks at the Request. If this value is not true, you then check a string against the Request.

Introduction to .NET Mobile

UserAgent to see if you can find some certain keywords. If any of these keywords exist, then you have a mobile device. If the regular expression fails, check the user agent string to see if it contains "iphone" or "android". You can add additional checks for other types of mobile devices, such as a blackberry. Now that you have a device detection method in place, call this method and set the IsMobileDevice property you added to your ProductViewModel class. Run the application using a desktop browser to ensure that your code detects a normal browser and returns the full HTML table.

Next, try running your application from an emulator. You may have to search the Internet for how to change the agent string using your unique browser, as they each work a little differently. Every Web developer should create applications with mobile in mind. More people browse sites with mobile devices than with desktop browsers now.

Develop Mobile Sites

Your Web application should respond accordingly. Different mobile devices support different programming languages. To support all types of mobile devices, developers must create one different application for each language. This tutorial is about how to develop applications with an extension to the. NET Mobile. If you want to study these subjects first, find the tutorials on our Home page.

You will need Windows to develop. If you want to read more about how to install. NET tutorial. Most web applications today use boring methods to present data to their viewers using grids or simple HTML tables. It takes less than 15 minutes and no expertise whatsoever to build your first chart and just a glance of it to captivate your audience. This fact is endorsed by our 12, customers and , users which include a majority of the Fortune companies. So go ahead, download your copy of FusionCharts and start "wow-ing" your customers now!

W3Schools is for training only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy. Copyright by Refsnes Data. All Rights Reserved.

Search W3Schools :. Table of contents. Introduction to.