Click here to Skip to main content
14,869,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi friends

I'm new to Mvc 3 Razor engine, i have a question. If i have to 4 text boxes having 2 textboxes for firstname and 2 textboxes for second name.

FirstName: @Model.reser_fname
LastName: @Model.reser_lname

FirstName: @Model.reser_fname
LastName: @Model.reser_lname

// script for popup box when the modify link is clicked
<script type="text/javascript">
$(document).ready(function () {
$('#modify').click(function () {
buttons: {
"save": function () {
Cancel: function () {
// div inside the popup box

Edit Details
FirstName : <input type="text" id="reser_fname" />
LastName : <input type="text" id="reser_lname" />

this is on a confirmation page, where as per razor code i have the first name and last name, now if i want to edit the first and last name,i click modify and i get a popup box, which has firstname and lastname. I enter i the details and click save button inside the popup. So the details on the confirmation page should change. how is that i can write a code for that save button where it changes the details on my confirmation page.

can anyone help..
Updated 11-Oct-12 2:57am
Sergey Alexandrovich Kryukov 10-Oct-12 16:20pm
No, it should not! Never repeat yourself.

1 solution

The simplest option is just to use javascript to copy across;

<!DOCTYPE html>

<html lang="en" xmlns="">
    <meta charset="utf-8" />
        Textbox 1 (FirstName):<input id="Text1" onchange="text1Change()" type="text" /></p>
        Textbox 2 (LastName):<input id="Text2" onchange="text2Change()" type="text" /></p>

        Textbox 3 (FirstName Copy):<input id="Text3" type="text" /></p>
        Textbox 4 (LastName Copy)<input id="Text4" type="text" /></p>

    <script type="text/javascript">

        function text1Change() {
            Text3.value = Text1.value;

        function text2Change() {
            Text4.value = Text2.value;


Arunprasath Natarajan 10-Oct-12 12:55pm
Will Javascript picks up the value like this?
No need to mention document.getElementById().value?
DaveAuld 10-Oct-12 13:01pm
I copied and pasted the code straight from a test page I chucked together to test this. There are other methods you could also use, like kepress events to do the trigger, or bind through jQuery.
I tested this in chrome (works), but it doesn't work in IE, so you will need to tweak to make it cross browser.
Arunprasath Natarajan 10-Oct-12 23:30pm
K tan q.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900