Tuesday, March 13, 2012

Textbox - additional features?

I'm dynamically creating some textboxes but also need to add some javascript
into them. What properties do I use to do this?

txtTextBox = New TextBox
txtTextBox.ID = "CAS" & dv(cnt)("InvID")
txtTextBox.Text = dv(cnt)("Cash")
txtTextBox.Columns = 9
plhResults.Controls.Add(txtTextBox)

I need to add: onfocus="DoMyFunc();"

Thanks.txtTextBox.Attributes.Add("onfocus","DoMyFunc();")

"Rob T" <RTorcellini@.DONTwalchemSPAM.com> wrote in message
news:uzbLDha8EHA.1408@.TK2MSFTNGP10.phx.gbl...
> I'm dynamically creating some textboxes but also need to add some
javascript
> into them. What properties do I use to do this?
> txtTextBox = New TextBox
> txtTextBox.ID = "CAS" & dv(cnt)("InvID")
> txtTextBox.Text = dv(cnt)("Cash")
> txtTextBox.Columns = 9
> plhResults.Controls.Add(txtTextBox)
> I need to add: onfocus="DoMyFunc();"
> Thanks.
Nevermind...found it:

txtTextBox.Attributes.Add("onfocus", "DoMyFunc();")

"Rob T" <RTorcellini@.DONTwalchemSPAM.com> wrote in message
news:uzbLDha8EHA.1408@.TK2MSFTNGP10.phx.gbl...
> I'm dynamically creating some textboxes but also need to add some
> javascript into them. What properties do I use to do this?
> txtTextBox = New TextBox
> txtTextBox.ID = "CAS" & dv(cnt)("InvID")
> txtTextBox.Text = dv(cnt)("Cash")
> txtTextBox.Columns = 9
> plhResults.Controls.Add(txtTextBox)
> I need to add: onfocus="DoMyFunc();"
> Thanks.
txtTextBox.Attributes.Add ("onFocus", "DoMyFunc();")

"Rob T" <RTorcellini@.DONTwalchemSPAM.com> wrote in message
news:uzbLDha8EHA.1408@.TK2MSFTNGP10.phx.gbl...
I'm dynamically creating some textboxes but also need to add some javascript
into them. What properties do I use to do this?

txtTextBox = New TextBox
txtTextBox.ID = "CAS" & dv(cnt)("InvID")
txtTextBox.Text = dv(cnt)("Cash")
txtTextBox.Columns = 9
plhResults.Controls.Add(txtTextBox)

I need to add: onfocus="DoMyFunc();"

Thanks.
Add the function to the attribute collection.

txtTextBox.Attributes.Add( "onfocus", "javascript: DoMyFunc();" );

HTH,

bill

"Rob T" <RTorcellini@.DONTwalchemSPAM.com> wrote in message
news:uzbLDha8EHA.1408@.TK2MSFTNGP10.phx.gbl...
> I'm dynamically creating some textboxes but also need to add some
javascript
> into them. What properties do I use to do this?
> txtTextBox = New TextBox
> txtTextBox.ID = "CAS" & dv(cnt)("InvID")
> txtTextBox.Text = dv(cnt)("Cash")
> txtTextBox.Columns = 9
> plhResults.Controls.Add(txtTextBox)
> I need to add: onfocus="DoMyFunc();"
> Thanks.

0 comments:

Post a Comment