Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.net Responsive text boxes not automatically fitting screens of mobilre devices

Posted on 2016-08-14
4
Medium Priority
?
266 Views
Last Modified: 2016-08-20
Hi

I am trying to build a web form in ASP.net 2015 that fits the screen of mobile devices. The first bit of code shows my markup for the page. The second bit of code shows the markup in my Site.Mobile.Master page. The  web page can  be seen at http://webappmobi.azurewebsites.net/
The text boxes aren't automatically fitting the size of different mobile device. What have I done wrong?

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Mobile.Master" CodeBehind="Default.aspx.vb" Inherits="Mobile1._Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <table>
        <tr>
            <td>
                <asp:Label ID="Label2" runat="server" Text="Username"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                    <!--Responsive TextBox style is in Site.Mobile.Master-->
                    <asp:TextBox ID="txtUsername" runat="server" CssClass="responsive-textbox"></asp:TextBox>
            </td>
        </tr>

Open in new window


   <%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site.Mobile.master.vb" Inherits="Mobile1.Site_Mobile" %>

<%@ Register Src="~/ViewSwitcher.ascx" TagPrefix="friendlyUrls" TagName="ViewSwitcher" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <!--Responsive TextBox style for text boxes to resize to the device-->
     <style type='text/css'>
    .responsive-textbox { width: 100%; }
  </style>


    <asp:ContentPlaceHolder runat="server" ID="HeadContent" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2>Lesedi Order System</h2>
        <asp:ContentPlaceHolder runat="server" ID="FeaturedContent" />
        <section class="content-wrapper main-content clear-fix">
            <asp:ContentPlaceHolder runat="server" ID="MainContent" />
        </section>
        <friendlyUrls:ViewSwitcher ID="ViewSwitcher1" runat="server" />
    </div>
    </form>
</body>
</html>

Open in new window

0
Comment
Question by:Murray Brown
  • 3
4 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 41755993
There is nothing there that needs to fit anything so what are you talking about?  What are you using to test your code?  A phone?  Chrome in emulation mode?
0
 

Author Comment

by:Murray Brown
ID: 41756152
For example                     <asp:TextBox ID="txtUsername" runat="server" CssClass="responsive-textbox"></asp:TextBox>

uses the style
  <style type='text/css'>
    .responsive-textbox { width: 100%; }
I want this to fit thewidth of the screen. When I view it on a Windows phone and an android phone this doesn't happen
0
 

Accepted Solution

by:
Murray Brown earned 0 total points
ID: 41756190
I found that moving the text boxes out of the table made a difference
0
 

Author Closing Comment

by:Murray Brown
ID: 41763509
It was difficult for anyone to understand my question
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question