Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
hello all...
i am developing a asp.net application using C#..
i want the value of the text box should be filled automatically according to the value of another text box........
 
Please Help........
Posted 28-Feb-11 0:41am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I would suggest you to give some time to learn and understand the basics.
 
i want the value of the text box should be filled automatically according to the value of another text box........
 
The simplest option is to enable AutoPostBack of the TextBox and handle it's TextChanged event.
 
The code will be something like:
 
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" ontextchanged="TextBox1_TextChanged"></asp:TextBox>
 
And in the code behind, it will be like:
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
    //assign value to another text box here.
}
 
This method is recommended if you need some database interaction or compulsory server side processing.
If the values can be processed on the client side, I recommend using JavaScript to do the same because this avoids a page post back.
 
The method I suggested above can also be done using AJAX.
 
Hope this helps!
  Permalink  
v2
Comments
Dipesh Gupta at 28-Feb-11 14:09pm
   
thanx for ur help.......
Ankur\m/ at 28-Feb-11 23:30pm
   
You are welcome. Do work on the suggestion given to you in the very first line.
 
And you may also accept the answer if it answers your question well.
Cheers!
Ankur
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I would like to suggest you use javascript for this
Collapse
<asp:textbox id="TextBox1" runat="server" >
<asp:textbox id="TextBox2" runat="server" >
 
and now on page_load write the line below
TextBox1.Attributes.Add("onblur","ManipulateValue(this)")
and then handle it in javascript
 
 
<script language="javascript">
function ManipulateValue(txt)
{
var text2=document.getElementById("<%=TextBox2.ClientID %>");
text2.value=txt.value;
}
</script>
here i assign the value of textbox1 to 2 but you can perform some task on that.
 
This will avoid postback which will be happen on server side code..
 
--Pankaj
  Permalink  
v3
Comments
Sreejith Gopinathan at 28-Feb-11 6:24am
   
+5 :) but onblur instead of onclick
code in play at 28-Feb-11 6:35am
   
thanks for quick correction i missed that.
Dipesh Gupta at 28-Feb-11 14:08pm
   
thanx........
Abhinav S at 28-Feb-11 23:17pm
   
You are welcome. Vote if it helped. :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

See this very simple example[^] - it will surely help you out.
  Permalink  
Comments
Dipesh Gupta at 28-Feb-11 14:09pm
   
thankx........

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,580
1 OriginalGriff 8,370
2 Peter Leow 4,859
3 Kornfeld Eliyahu Peter 3,210
4 Maciej Los 2,301


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 28 Feb 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100