Wednesday, February 15, 2012

Copy data from one Textbox to another Textbox while User entering data

on the keypress event of the textbox write the following code
document.getElementByID('<%=TextBox2.ClientID%>').Text = document.getElementByID('<%=TextBox1.ClientID%>').Text
<asp:textbox id="TextBox" runat=server onkeypress="document.getElementByID('<%=TextBox2.ClientID%>').Text =
document.getElementByID('<%=TextBox1.ClientID%>').Text"> </asp:textbox>
onblur event of the textbox write the following code
//javaScript
function fnFromToTextBox(firstTxtBox,secondTxtBox)
{
secondTxtBox.value=firstTxtBox.value;
}
//on Code behind
txtCompany.Attributes.Add("onblur", "fnFromToTextBox(txtCompany,txtBilling)");
Using Keyup:
<asp:TextBox id="TextBox1" onkeyup="document.getElementById("TextBox2").value = this.value;"></asp:TextBox>

No comments:

Post a Comment