On Jul 21, 11:25 am, Göran Andersson <gu...@guffa.comwrote:
Christian Cambier wrote:
Hi,
I have a textbox in a web user control.
I then add the usercontrol to a web form. I also add a label in the
web form.
Now, when I press a key in the textbox, i want to display some text in
the label.
I tried by raising events as used in Winforms but it is not as easy as
that apparently.
Any ideas?
thank you
Chris
If you want to raise a server event for every key press, the page will
be reloaded for every key that you press, which is not very practical.
For something simple like displaying some text on the page, you should
use a client event instead, i.e. Javascript.
Example:
onkeydown="document.getElementById('ElementForShow ingMessage').innerHTML='message';"
--
Göran Andersson
_____http://www.guffa.com
Hello,
that is to set the text of a control Ok, but my situation is a little
more complicated than that ... allow me to explain what I really try
to implement.
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 control on an asp.net form, one for each
value.
added as well ON THE FORM (and not in the user control) are a button
(Add) and a label to display the result
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 is 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?
Chris