raising events in javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cmrchs@gmail.com

    raising events in javascript

    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
  • Munna

    #2
    Re: raising events in javascript

    Hi,

    In page_load event of the user control add attribute of the
    textboxes...
    like textbox1.attrib ute.add("onkeyp ress","somefunc tion();");

    in page just add a script like this..

    function somefunction(){
    document.GetEle mentById('label sclientid').val ue = "";
    }

    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




    Comment

    Working...