Execute Client Side Script from TextBox in Template column

D

David C. Churchill

I have a datagrid with 3 template columns, each containing a textbox.
I want to handle one of the textbox's OnTextChanged Event and have some
client side JavaScript execute. The client side code will update one of the
textbox's values by subtracting the values in the other 2.

I'm able to add the JavaScript using RegisterClientScript and added the
script function to the textbox control using Attribute.Add in the DataGrid's
ItemDataBound event.

When I load the page I get nothing, clicking view source shows the
JavaScript code and each controls OnTextChanged event handler.

Any ideas what I'm doing wrong? Is this even possible? I really don't want
to do this server side as the postbacks with a datagrid holding over 100
rows can be pretty annoying.

Any help would be greatly appreciated.

Thanks,
 
D

David C. Churchill

Nevermind,
I fixed it:
I was using:
Attribute.Add("OnTextChanged", "myScript()")
But I should have been using: Attribute.Add("OnChange", "myScript()")

^^^^^^^^^^^^^
I guess it helps to actually know JavaScript and the DHTML objects before
you try to use them :)

Thanks anyway,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top