Friday, May 21, 2010

How to get the text from asp:textbox to normal input type:text?

i have a asp:textbox which has strings for its value


i want to copy that string to a normal


textbox input type:text value=....





plz help and do give me somewhat a good code instead of just a single line of code

How to get the text from asp:textbox to normal input type:text?
It sounds like you have a separate %26lt;input type="text" /%26gt; element and that you want to copy the value of your ASP.NET textbox.





You can do this with some javascript, but the trick is getting the Id of the ASP.NET textbox which may vary depending on which parent container is used to drop it on the page (for instance if you have this code in a usercontrol that is reused).





%26lt;asp:TextBox id="myTextBox" Text="asdf" runat="server"%26gt;


%26lt;input id="myInput" type="text"%26gt;


%26lt;script type="text/javascript"%26gt;


function copyValue()


{


var myTextBox = document.getElementById('%26lt;%= this.myTextBox.ClientID%%26gt;');


var myInput = document.getElementById('myInput');


myInput.value = myTextBox.value;


}


%26lt;/script%26gt;


No comments:

Post a Comment