Click here to Skip to main content
15,870,165 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys,

I got a problem here as you see i have created 3 textbox. When i input numbers on the first and second textbox i want the 3rd text box be automatically calculated meaning there is no button. Please help. I tried it but nothing happens
Here is my code:
VB
 Protected Sub TF_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TF.TextChanged
If IsNumeric(Fattend.Text) AndAlso IsNumeric(FHour.Text) Then

    TF.Text = CInt(Fattend.Text) * CInt(Fhour.Text)
End If
Posted
Updated 16-May-11 21:35pm
v3

yes you can do that. Set textbox2's property to Autopostback = true and create an TextChangedevent on textbox2 and store the result into textbox3.

But the same thing you can do with Javascript and JQuery without any postback.
 
Share this answer
 
Comments
saxenaabhi6 17-May-11 7:54am    
my 5 for correct answer.
You cannot achieve this in ASP.NET server side as the event will be fired only when postback occurs. You can solve this by using client side code, which means you need to use JavaScript or VBScript.

I hope you get my point.
 
Share this answer
 
Comments
janwel 17-May-11 3:43am    
Sir is there any tutorial regarding this matter?
Wild-Programmer 17-May-11 4:14am    
Just google out, you will get lots of them.
Perhaps what you actually want to handle is the Fattend and Fhour TextChnaged events, instead of your result TextBox changed?
 
Share this answer
 
Comments
janwel 17-May-11 3:47am    
sir im gonna type two numbers on Fattend(first textbox) and FHour(second textbox) and there is a ready formula on TF(solution textbox)
I just want that when i input a number on Fattend and FHour the solution automatically display on TF textbox

sorry for my english.
is there any possible way regarding this matter?
HI janwel783,
You can use raw ajax or what we called classic ajax it simple you have to use Httpxmlrequest and Httpxmlresponse object that all .


Try this http://www.aspjax.com/[^]

Let me know if you find any difficulty regading the same.


Enjoy Life :)
 
Share this answer
 
v2
Comments
janwel 17-May-11 3:51am    
ill try to read it sir ^_^ thanks
As amit says you can achieve it via jscript
have you tried using JQuery to do this:
like adding function on key up of your TF textbox doing the code below on that function

<br />
$("#"+<%= TF.ClientID %>).val($("#"+<%= Fattend.ClientID %>).val() * $("#"+<%= Fhour.ClientID %>).val())<br />
 
Share this answer
 
Comments
janwel 17-May-11 3:52am    
the problem sir is this the first time i encountered this cenario
janwel 17-May-11 3:52am    
where will i put that sir?
janwel 17-May-11 3:53am    
will i put that on asp textbox attribute?
saxenaabhi6 17-May-11 4:00am    
add this in your html head section to include jquery in your code
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>

then add a javascript function on your 'FHour' text box as
<asp:TextBox ...... onkeyup="dothis()" ....../>

then add the function on your page
<script>
function dothis(){
$("#"+<%= TF.ClientID %>).val($("#"+<%= Fattend.ClientID %>).val() * $("#"+<%= Fhour.ClientID %>).val())
}
</script>
janwel 17-May-11 4:02am    
sir is there any tutorial regarding that matter? Sir itis my first time to encounter that kind of program.. Thank you very much sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900