Solved

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

Posted on 2016-08-14
4
21 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:murbro
  • 3
4 Comments
 
LVL 82

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:murbro
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:
murbro 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:murbro
ID: 41763509
It was difficult for anyone to understand my question
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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)

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now