Murray Brown
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%;
}
Dim tb As New TextBox
tb.ID = "Control" 1
tb.CssClass = "xTextBoxHundredPercent"
Me.Panel_Controls.Controls
Here is the class
.xTextBoxHundredPercent {
width: 100%;
}
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?
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.Mob ile.Master " CodeBehind="Dynamic Data.aspx.vb" Inherits="Mobile1.Order" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head Content" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Feat uredConten t" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Main Content" 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:Labe l>
<asp:Label ID="lblSaveSuccess" runat="server" ForeColor="#006600"></asp: Label>
<asp:Button ID="btnSave" runat="server" Text="Button" Width="100%" />
</asp:Panel>
</asp:Content>
Me.Form.Controls.Add(tb)
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Mob
<asp:Content ID="Content1" ContentPlaceHolderID="Head
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Feat
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Main
<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:Labe
<asp:Label ID="lblSaveSuccess" runat="server" ForeColor="#006600"></asp:
<asp:Button ID="btnSave" runat="server" Text="Button" Width="100%" />
</asp:Panel>
</asp:Content>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. I set the Panel to 100%