ASP.net VB.net Set dynamically added TextBox to stretch accross screen

Murray Brown
Murray Brown used Ask the Experts™
on
Hi. I add a text box to my ASP.net panel using the following code. The CssClass used is in my Site.css file. The TextBox doesn't stretch across the width of the page as I would expect
                   Dim tb As New TextBox
                     tb.ID = "Control" 1
                     tb.CssClass = "xTextBoxHundredPercent"
                     Me.Panel_Controls.Controls.Add(tb)

Here is the class
    .xTextBoxHundredPercent {
     width: 100%;
 }
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Ramkisan JagtapLead Developer

Commented:
May be your panel has fixed width, so your child control will get the 100% width of its parent i.e. panel where you have added the button. If possible can you please post you full code here?
Murray BrownASP.net/VSTO Developer

Author

Commented:
Hi. I thought of that and tried the following code but it didn't work. See my Markup for the page below
Me.Form.Controls.Add(tb)

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

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Panel ID="Panel_Controls" runat="server">
    </asp:Panel>
        <asp:Panel ID="Panel_Save" runat="server">
            <asp:Label ID="lblSaveError" runat="server" ForeColor="Red"></asp:Label>
            <asp:Label ID="lblSaveSuccess" runat="server" ForeColor="#006600"></asp:Label>
            <asp:Button ID="btnSave" runat="server" Text="Button" Width="100%" />
    </asp:Panel>
</asp:Content>
Lead Developer
Commented:
Does other controls in panel_controls get 100% width?
Try to set width of panel to 100%
Murray BrownASP.net/VSTO Developer

Author

Commented:
Thanks. I set the Panel to 100%

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial