DataBinding

G

Guest

I am wanting to make the text value of one control the text value of another
control and I want to do this in the HTML code rather in the code behind.

I have tried the following:

<asp:TextBox ID="txtACF2ID" runat="server" MaxLength="8" Text="<%
=txtACFIIID.Text %>"></asp:TextBox>

<asp:TextBox ID="txtACF2ID" runat="server" MaxLength="8" Text="'<%
=txtACFIIID.Text %>'></asp:TextBox>

I tried without the " or ' but I get an error that "server tags cannot
contain <%... %>

So can this be done in the HTML code?
 
G

Guest

Hi,

That would work if you were using an input text box without making it a
server control ( not adding the runat="server" attribute).

But if you plan to use a server text box then you need to add a script tag
right below your asp:textbox.

<asp:TextBox ID="txtACF2ID" runat="server" MaxLength="8" ></asp:TextBox>
<script type="text/javascript">

document.getElementById("txtACF2ID").value =
document.getElementById("txtACFIIID").value;

</script>

The script tag would set the text property of the asp:textbox as soon as the
control is loaded. But then if the value of the txtACFIIID text box is
changed, the same change will not reflect in the txtACF2ID textbox. But that
again has to be handled in the script.

I hope this helps..

-Parvathy Padmanabhan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top