ASP.NET - automate value of the text box on the tab ao another textbox

Asked By aman on 03-Jul-11 02:57 AM
hi all,

i want to get value into textbox on the tab of another textbox ....


soo please provide me with some example so that i can get a better idea on it

thanks and regards
Aman Khan
dipa ahuja replied to aman on 03-Jul-11 03:41 AM
You can do this using the JavaScript function

► Add javascript function:

<script type="text/javascript">
    function disp() {
      var name = document.getElementById('<%=TextBox1.ClientID %>').value;
      document.getElementById('<%=TextBox2.ClientID %>').value = name;
    }  
  </script>
► Bind the function with textbox onblur event in page_load
 protected void Page_Load(object sender, EventArgs e)
  {
    TextBox1.Attributes.Add("onblur""disp()");
  }
Hope this will help you!

Reena Jain replied to aman on 03-Jul-11 04:28 AM
hi,

Use javascript function and let me know

function writeMessage()
{
 
var tabContainer = document.getElementById(TabContainer1.ClientID);
var tabPanel1 = tabContainer.FindControl(TabPanel1.ClientID);
var textBox4 = tabPanel1.FindControl(TextBox4);
var textBox3 = tabPanel1.FindControl(TextBox3);
 
textBox4.value = textBox3.value;
 
}
aman replied to dipa ahuja on 04-Jul-11 02:28 AM
hi Deepa,

First of all thanks for ur help, ur code help me a lot but i want that it should take only the first character of the textbox

thanks and regards
Aman Khan 
dipa ahuja replied to aman on 04-Jul-11 02:35 AM
Use the javascript function chatAt

<script type="text/javascript">
    function disp() {
      var name = document.getElementById('<%=TextBox1.ClientID %>').value;
      document.getElementById('<%=TextBox2.ClientID %>').value = name.charAt(0);
    }  
  </script>
Jitendra Faye replied to aman on 04-Jul-11 04:37 AM
For that you have to Use onblur event of TextBox.

Use this code-

<script type="text/javascript">
    function FillValue()
    {
    var txt1 = document.getElementById("TextBox1").value;
    var txt2 =document.getElementById("TextBox2");
    txt2.value=txt2.value;
    } 
  </script>

Call this Fucntion in onblur Event of TextBox, like this-

<input type="Text" id="TextBox1" onblur="FillValue()">
<input type="Text" id="TextBox2" >

Hope this will help you.