I am programatically adding labels, textboxes, listboxes, etc to a
placeholder.  Everything works, including most of the stylesheet
settings, except labels are ignoring the settings for width, height,
and vertical-align.

the end result is something like this:

|Label | |Textbox|
|User name: | |____________|
|Pwd: | |____________|


Current code:

html code:

<style type="text/css">
.body { color: #000000; font-family: verdana,Tahoma,arial; background-
color: transparent }
.ctlListBox             { font-size: 9pt; text-align: left; border-style:solid;
border-width:thin; border-color:Black; height: 80px; width:300px;
margin-bottom: 7px; }
.InfoEror               { font-size: 9pt; font-weight: bold;   color: #ff0000; 
text-
align: center; margin-top: 15px; }
.pusHeader              { font-size: 8pt; font-weight: bold;   font-family:
arial,Tahoma,verdana; vertical-align : middle; text-align: right;
width:150px; }
.pusListBox             { font-size: 9pt; font-weight: normal; vertical-align:
middle;  text-align: right; height: 120px; width: 250px; }
.pusDetail              { font-size: 9pt; font-weight: normal; vertical-align:
top; text-align: left; width: 250px; }
</style>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:placeholder id="ctlPlaceholder" runat="server"></asp:placeholder>

In code behind:

  Labels:
    // it does not matter if labels are constructed using
ParseControl, or
    //  - a la Textboxes ( see below ), or
    //  - wrapped in a DIV using either a class= or style=, or
    //  - wrapped in a SPAN using either a class= or style=

        string strHTML = "<br/><label class='pusHeader'>" + myText + "</
label>";
        Control ctrlDynamic = Page.ParseControl( strHTML );
        ctlPlaceholder.Controls.Add(ctrlDynamic);

Textboxes, etc:

        TextBox TextBox1 = new TextBox();
        TextBox1.ID = "TEXT_" + myFieldName + "_" + myRowID;

        //convert int to proper format
        xWidth = myWidth;
        xHeight = myHeight;

        TextBox1.Height = xHeight;
        TextBox1.Width = xWidth;
        TextBox1.Text = myDefaultValue;
        TextBox1.Wrap = false;
        TextBox1.TextMode = TextBoxMode.SingleLine;
        TextBox1.CssClass = myCSS;
        ctlPlaceholder.Controls.Add(TextBox1);

I can provide launch codes for you to see a live example of this
problem.



Option #2
I do not know if it's possible to use a DataGrid like a PlaceHolder so
that the DG would look something like:

   150px         250px
|Label 1 | | Textbox 1                |
|Label 2 | | ListBox 1                 |
|Label 3 | | DropDownList 1        |
|Label 4 | | ListBox 2                 |
|Label 5 | | Textbox 2                |
|Label 6 | | Textbox 3                |

and change to ListBox1.SelectedIndex would re-populate ListBox2 with
the new information.

Thank you,

John

Reply via email to