error when updating forms with 'mvc'

I have forms on a /check/confirm.cshtml page with two buttons, 'Update' & 'Confirm'
When I click on the Update button, it does not update the form, but is transferred to page
/checkout/completed.cshtml
For clarity the complete code is below:
Thanks in advance for any help given.
@model CheckoutConfirmModel
@using Nop.Core.Domain.Orders;
@using Nop.Web.Models.Checkout;
@using Nop.Web.Models.Common;
@using Nop.Web.Models.ShoppingCart;
@{
    Layout = "~/Views/Shared/_ColumnsThree.cshtml";
    ViewBag.Title = "Create";
    Int32 nCount = Convert.ToInt32(Session["nCount"]);
    var result = "";
    if (IsPost)
    {
        var firstName = Request["FirstName"];
        var lastName = Request["LastName"];
        var email = Request["Email"];
        var userData = firstName + "," + lastName +
            "," + email + Environment.NewLine;
        var dataFile = Server.MapPath("~/App_Data/data" + @Session["CustId"] + ".txt");
        File.AppendAllText(@dataFile, userData);
        result = "Information saved.";
    }
}
<div id="page shopping-cart-page" style="border:0px solid red; width:680px; height:130px; background-color: white; margin-left:15px;">
    @Html.Action("CheckoutProgress", "Checkout", new { step = CheckoutProgressStep.Cart })
    <div class="page-title"><br />
        <h2>Your&nbsp;@T("ShoppingCart")</h2>
        <span id="spanEnquiry" style="position:absolute;top:265px;left:550px;color:Black;" >
        <b>Thank you for enquiring about this product.</b></span>
        </div>
</div>
<h2>&nbsp;&nbsp;&nbsp;&nbsp;Order</h2>
@using (Html.BeginRouteForm("CheckoutConfirm", "Confirm", FormMethod.Post, new { id = "confirm-order-form" }))
{
    @*Based on your object to change the Id to the Corresponding property name*@
    @Html.HiddenFor(Model => Model.id)
    <div id="fldset" style=" position:relative; background-color:White; left:15px; width:680px;">
    <br />
    <fieldset>
        <legend>Information</legend>
                <p>Please give us a little more information about your printing / embroidery requirements<br />               
                Any additional information on the garments you want us to have?<br />
                Only complete the following information once you have finished adding products<br /> 
                to your enquiry and are ready to submit<br />
                </p>
                <p>
                Please give us a little more information about your printing / embroidery requirements<br />
                (e.g. position of the logo, sizing, number of colours, if plain text is required...): *
                </p>  
        <input type="submit" name="nextstep" value="@T("Checkout.ConfirmButton")" class="Button3" /><br />    
    </fieldset>
    </div>
}
            <div class="editor-field" style=" position:relative; background-color:White; left:15px; width:680px;">
            <fieldset>
            <legend>Information</legend>     
           <form id="form1" method="post" action="Confirm" >
           @*Based on your object to change the Id to the Corresponding property name*@
           @Html.HiddenFor(Model => Model.id)
           <table>
            <tr>
                <td>First Name:</td>
                <td><input id="FirstName" name="FirstName" type="text" /></td>
            </tr>
            <tr>
                <td>Last Name:</td>
                <td><input id="LastName" name="LastName" type="text" /></td>
            </tr>
            <tr>
                <td>Email:</td>
                <td><input id="Email" name="Email" type="text" /></td>
            </tr>
            <tr>
                <td>@Html.ActionLink("Go to Display", "", "Checkout/Completed")</td>
                <td><input type="submit"  value="Update" class="Button3"/></td>
            </tr>
        </table>
        </form>
        </fieldset>
        </div>
        <div style=" position: relative; top:0px; left:15px; width:705px;width:680px; background-color:White; color:Maroon; font-size:small;">
        <fieldset>
        <legend>Information</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.OrderEnquiry)
        </div>
        <div class = "order-enquiry">
            AddInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:@Session["AdditionalInformation"]#<br />
            CustomeId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:@Session["CustId"]#<br />
         </div>
            
            @if (result != "")
            {
            <p>Result: @result</p>
            }
        </fieldset>
        </div>

Open in new window

homeshopperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
What do you mean by "update the form?" What is it updating? As you've written it, the update button is a submit-type <input>, so it will post the form when you click it.
0
homeshopperAuthor Commented:
Hi Kaufmed,
Just to clarify the confusion, there are two code blocks below.
The first code block is the confirm page as it was originally.
It has a confirm button that transfers the page to the completed page.
The second code block is what I called an update page.
It has a button that should update or append the content of the textboxes
to a text file named as the customerId and stay on the same page,
but it does not, it just transfers the confirm page to the completed page
and the text file is not updated. I also wanted to conbine it all as one page.
Thanks in adavnce for any help given.
Best Regards, Ian.
@model CheckoutConfirmModel
@using Nop.Core.Domain.Orders;
@using Nop.Web.Models.Checkout;
@using Nop.Web.Models.Common;
@using Nop.Web.Models.ShoppingCart;
@{
    Layout = "~/Views/Shared/_ColumnsThree.cshtml";
    ViewBag.Title = "Create";
    Int32 nCount = Convert.ToInt32(Session["nCount"]);
}
<div id="page shopping-cart-page" style="border:0px solid red; width:680px; height:130px; background-color: white; margin-left:15px;">
    @Html.Action("CheckoutProgress", "Checkout", new { step = CheckoutProgressStep.Cart })
    <div class="page-title"><br />
        <h2>Your&nbsp;@T("ShoppingCart")</h2>
        <span id="spanEnquiry" style="position:absolute;top:265px;left:550px;color:Black;" >
        <b>Thank you for enquiring about this product.</b></span>
        </div>
</div>
<h2>&nbsp;&nbsp;&nbsp;&nbsp;Order</h2>
@using (Html.BeginRouteForm("CheckoutConfirm", "Confirm", FormMethod.Post, new { id = "confirm-order-form" }))
{
    @*Based on your object to change the Id to the Corresponding property name*@
    @Html.HiddenFor(Model => Model.id)
    <div id="fldset" style=" position:relative; background-color:White; left:15px; width:680px;">
    <br />
    <fieldset>
        <legend>Information</legend>
                <p>Please give us a little more information about your printing / embroidery requirements<br />               
                Any additional information on the garments you want us to have?<br />
                Only complete the following information once you have finished adding products<br /> 
                to your enquiry and are ready to submit<br />
                </p>
                <p>
                Please give us a little more information about your printing / embroidery requirements<br />
                (e.g. position of the logo, sizing, number of colours, if plain text is required...): *
                </p>  
        <input type="submit" name="nextstep" value="@T("Checkout.ConfirmButton")" class="Button3" /><br />    
    </fieldset>
    </div>
}

Open in new window

@model CheckoutConfirmModel
@using Nop.Core.Domain.Orders;
@using Nop.Web.Models.Checkout;
@using Nop.Web.Models.Common;
@using Nop.Web.Models.ShoppingCart;
@{
    var result = "";
    if (IsPost)
    {
        var firstName = Request["FirstName"];
        var lastName = Request["LastName"];
        var email = Request["Email"];
        var userData = firstName + "," + lastName +
            "," + email + Environment.NewLine;
        var dataFile = Server.MapPath("~/App_Data/data" + @Session["CustId"] + ".txt");
        File.AppendAllText(@dataFile, userData);
        result = "Information saved.";
    }
}
<div class="editor-field" style=" position:relative; background-color:White; left:15px; width:680px;">
            <fieldset>
            <legend>Information</legend>     
           <form id="form1" method="post" action="Confirm" >
           @*Based on your object to change the Id to the Corresponding property name*@                  
           @Html.HiddenFor(Model => Model.id)                   
           <table>
            <tr>
                <td>First Name:</td>
                <td><input id="FirstName" name="FirstName" type="text" /></td>
            </tr>
            <tr>
                <td>Last Name:</td>
                <td><input id="LastName" name="LastName" type="text" /></td>
            </tr>
            <tr>
                <td>Email:</td>
                <td><input id="Email" name="Email" type="text" /></td>
            </tr>
            <tr>
                <td>@Html.ActionLink("Go to Display", "", "Checkout/Completed")</td>
                <td><input type="submit"  value="Update" class="Button3"/></td>
            </tr>
        </table>
        </form>
        </fieldset>
        </div>
        <div style=" position: relative; top:0px; left:15px; width:705px;width:680px; background-color:White; color:Maroon; font-size:small;">
        <fieldset>
        <legend>Information</legend>
        <div class="editor-label">  
        @Html.LabelFor(model => model.OrderEnquiry)     
        </div>
        <div class = "order-enquiry">
            AddInfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:@Session["AdditionalInformation"]#<br />
            CustomeId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:@Session["CustId"]#<br />
         </div>
            
            @if (result != "")
            {
            <p>Result: @result</p>
            }
        </fieldset>
        </div>

Open in new window

0
homeshopperAuthor Commented:
I have found a solution myself as follows.
Changed <form id="form1" method="post" action="Confirm" >
to            <form id="form1" method="post" action="Confirm" >
Then in the CheckoutController.cs new routine as follows based on the Confirm routine,
but without redirect code etc.
[HttpPost, ActionName("txtConfirm")]
        [ValidateInput(false)]
        public ActionResult ConfirmOrder2()
        {
            //validation
            //
            //return RedirectToRoute("CheckoutCompleted");
              return View(model);
        }

Open in new window

0
homeshopperAuthor Commented:
Typo in post above, should be <form id="form1" method="post" action="txtConfirm" >
[HttpPost, ActionName("txtConfirm")]
        [ValidateInput(false)]
        public ActionResult ConfirmOrder2()
        {
            //validation
            //
            //return RedirectToRoute("CheckoutCompleted");
              return View(model);
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
homeshopperAuthor Commented:
I found the solution myself
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.