Execute Client Side Script from TextBox in Template column

Discussion in 'ASP .Net Datagrid Control' started by David C. Churchill, Nov 20, 2003.

  1. 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,
     
    David C. Churchill, Nov 20, 2003
    #1
    1. Advertising

  2. 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,

    "David C. Churchill" <> wrote in message
    news:...
    > 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,
    >
    >
     
    David C. Churchill, Nov 20, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Magnus Blomberg
    Replies:
    3
    Views:
    735
    Magnus Blomberg
    Apr 14, 2005
  2. Boss302
    Replies:
    0
    Views:
    1,086
    Boss302
    Nov 21, 2006
  3. turboJeeper
    Replies:
    2
    Views:
    377
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Feb 1, 2007
  4. john22
    Replies:
    0
    Views:
    589
    john22
    Nov 6, 2007
  5. Bogdan
    Replies:
    2
    Views:
    678
    Bogdan
    Jun 9, 2008
Loading...

Share This Page