Avatar of Murray Brown
Murray Brown
Flag for United Kingdom of Great Britain and Northern Ireland asked on

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

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%;
 }
ASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
Murray Brown

8/22/2022 - Mon
Ramkisan Jagtap

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 Brown

ASKER
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>
ASKER CERTIFIED SOLUTION
Ramkisan Jagtap

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Murray Brown

ASKER
Thanks. I set the Panel to 100%
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck