Home All Groups Group Topic Archive Search About

Placeholder Object Question

Author
9 Jun 2006 5:31 PM
JohnJohn
Hello.  I have a VB.NET 2005 web application.  I set up a placeholder control
that I use to optionally add a textbox control at runtime (doesn't happen
every time).  This works very well.  However, I need to be able to manipulate
the value (via client-side scripting) in the textbox after the page is
rendered.  In order to do that, I need to know the value of the "Name"
attribute that is assigned to my textbox by the placeholder control.

Does anyone know how I can obtain the "name" attribute assigned to the
textbox BEFORE the page is rendered?  I tried SETTING the value of the name
attribute, but that doesn't work...it still uses the name it generates, and
ADDS the name attribute that I specified.  The net effect of that is that the
name I specified gets ignored.  It names my textbox something like "ctl02". 
Incidentally, here is the code I use to create the textbox at runtime:

            Dim thisTextBox As TextBox = New TextBox
            thisTextBox.Text = FormatNumber(thisTranFee, 2, -1, 0, -1)
            thisTextBox.Style("TEXT-ALIGN") = "Right"
            thisTextBox.Attributes.Add("onchange", "CalcTotalPayoff()")
            thisTextBox.Attributes.Add("ID", "TransFee")
            thisTextBox.Width = 100
            ph_TransactionFee.Controls.Add(thisTextBox)

Thanks in advance,
John

Author
9 Jun 2006 6:16 PM
Mythran
Show quote Hide quote
"JohnJohn" <JohnJ***@discussions.microsoft.com> wrote in message
news:6C26BF8E-435E-4849-8DA5-6153924C8E04@microsoft.com...
> Hello.  I have a VB.NET 2005 web application.  I set up a placeholder
> control
> that I use to optionally add a textbox control at runtime (doesn't happen
> every time).  This works very well.  However, I need to be able to
> manipulate
> the value (via client-side scripting) in the textbox after the page is
> rendered.  In order to do that, I need to know the value of the "Name"
> attribute that is assigned to my textbox by the placeholder control.
>
> Does anyone know how I can obtain the "name" attribute assigned to the
> textbox BEFORE the page is rendered?  I tried SETTING the value of the
> name
> attribute, but that doesn't work...it still uses the name it generates,
> and
> ADDS the name attribute that I specified.  The net effect of that is that
> the
> name I specified gets ignored.  It names my textbox something like
> "ctl02".
> Incidentally, here is the code I use to create the textbox at runtime:
>
>            Dim thisTextBox As TextBox = New TextBox
>            thisTextBox.Text = FormatNumber(thisTranFee, 2, -1, 0, -1)
>            thisTextBox.Style("TEXT-ALIGN") = "Right"
>            thisTextBox.Attributes.Add("onchange", "CalcTotalPayoff()")
>            thisTextBox.Attributes.Add("ID", "TransFee")
>            thisTextBox.Width = 100
>            ph_TransactionFee.Controls.Add(thisTextBox)
>
> Thanks in advance,
> John

If I understand correctly, you want to get a reference to the textbox in the
client-side script.  To get the reference, you need to use the id of the
textbox...as seen on the client...

You have to use textBox1.ClientID to get the id...but ClientID is on the
server...so you'll have to pass that to the client script call (onclick or
whatever).

HTH,
Mythran