Solved

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

Posted on 2016-08-14
4
131 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 83

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
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)

734 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