Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid && Javascript

Status
Not open for further replies.

Alcar

Programmer
Sep 10, 2001
595
US
I believe I saw it somewhere here already but I can't find it.

Given that I have a textbox in the Edit Template of my DataGrid, I want to add a Javascript to one of it's events.

I am trying to use the javascript code "getElementById"
but even if I use the UniqueID, it seems like it cannot find it (even if the datagrid is in edit mode)

any hints on how to accomplish this? here is my code:

StringBuilder product = new StringBuilder();
product.Append(&quot;<Script Language=javascript>&quot;);
product.Append(&quot;function Recalculate() {&quot;);
product.Append(&quot;document.getElementById('&quot;);
product.Append(txbTotal.UniqueID);
product.Append(&quot;').value = document.getElementById('&quot;);
product.Append(txbQuantity.UniqueID);
product.Append(&quot;').value * document.getElementById('&quot;);
product.Append(txbPrice.UniqueID);
product.Append(&quot;').value&quot;);
product.Append(&quot;}&quot;);
product.Append(&quot;</Script>&quot;);
RegisterStartupScript(&quot;Product&quot;, product.ToString());
txbQuantity.Attributes.Add(&quot;OnChange&quot;, &quot;javascript:Recalculate()&quot;);
txbPrice.Attributes.Add(&quot;OnChange&quot;, &quot;javascript:Recalculate()&quot;);

thanks!! Daren J. Lahey
Just another computer guy...
If you are unsure of forum etiquette check here FAQ796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top