raising events in javascript

C

cmrchs

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
 
M

Munna

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
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top