passing two different textbox values in two different textbox

Dani AI

Generated

As and pointed out, the goal is simply to transfer the contents of one control into another. Which technique to use depends on context: a web page (client-side) or a desktop/web server control (server-side). Below are concise, practical options and pitfalls to watch for.

On a web page use the input value and wire an event so updates happen when you want (live, on blur, or with an explicit copy button). Example: two source inputs and two target inputs kept in sync using addEventListener('input', …) or a single click handler to copy both values at once.

<!-- minimal HTML -->
<input id="src1">
<input id="src2">
<input id="dst1">
<input id="dst2">
<button id="copyBtn">Copy</button>

<!-- minimal JS -->
const copyBtn = document.getElementById('copyBtn');
copyBtn.addEventListener('click', () => {
  document.getElementById('dst1').value = document.getElementById('src1').value;
  document.getElementById('dst2').value = document.getElementById('src2').value;
});

If working across pages or submitting to a server, send the values via a form POST/GET or use AJAX, or persist on the client with sessionStorage/localStorage for single-page flows. For desktop frameworks (Windows Forms, WPF) the equivalent is the control text property on the server side; consult the framework docs for exact property names and binding options.

Best practices: validate and trim input before copying, avoid inserting raw HTML into a target (use text properties), debounce frequent events for performance, and ensure labels and ARIA attributes for accessibility. For web details see MDN on HTMLInputElement.value and the input event: HTMLInputElement.value, input event. For WinForms text handling see Microsoft Docs: TextBox.Text.

Recommended Answers

All 2 Replies

Use the text property and assign the value of another one to it.

commented: Spot on +7

Use Textbox1.text=Textbox2.text for assigning value of one textbox to another text box.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.