raising events in javascript

Discussion in 'ASP .Net' started by cmrchs@gmail.com, Jul 22, 2008.

  1. Guest

    Hi,

    I am creating a simple calculator to add 2 values.

    For the user to enter a value, I have created a web user control
    consisting of a textbox and some additional logic.
    I add 2 of those webuser controls on an asp.net form, one for each
    value.
    added as well ON THE FORM (and not in the user control) are a button
    (btnAdd) and a label to display the result (lblResult)
    Now, i run it ... enter 2 values, press Add and the result is
    displayed in the label ... easy.

    But what i want now is that when I change one of the values in one of
    the textboxes in the user control (during 'onkeypress' in javascript)
    is that the text in the label control be cleared.
    for this to happen, I can not just implement it in the onkeypress of
    the textbox, since the label control is not part of the user control
    you see?

    so what I need, I think, is to raise some event in onkeypress (in the
    webuser control) and implement the event handler in the host form but
    whithout a postback to the server !

    any ideas?

    thank you
    Chris
     
    , Jul 22, 2008
    #1
    1. Advertising

  2. Munna Guest

    Hi,

    In page_load event of the user control add attribute of the
    textboxes...
    like textbox1.attribute.add("onkeypress","somefunction();");

    in page just add a script like this..

    function somefunction(){
    document.GetElementById('labelsclientid').value = "";
    }

    but if you want to recalculate the values again...
    perhaps you can use ajax to give the user a smoth user experience

    ontextchange of both textboxes take the value from both and send it to
    server via ajax to calculate...
    or callback show result to label..

    BEST OF LUCK

    --------------
    Munna

    www.munna.shatkotha.com/blog
    www.munna.shatkotha.com
    www.shatkotha.com
     
    Munna, Jul 22, 2008
    #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. David Smith

    raising events!

    David Smith, Dec 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    540
    David Smith
    Dec 5, 2003
  2. David Smith

    Help raising events

    David Smith, Dec 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    526
    David Smith
    Dec 8, 2003
  3. Colin Young
    Replies:
    5
    Views:
    617
    Colin Young
    Oct 20, 2003
  4. Jonel Rienton
    Replies:
    2
    Views:
    4,937
    Jonel Rienton
    Nov 24, 2003
  5. S. Justin Gengo
    Replies:
    0
    Views:
    519
    S. Justin Gengo
    Nov 24, 2003
Loading...

Share This Page