Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7808399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:07:28+00:00 2026-06-02T03:07:28+00:00

i have mvc application in that i have one form which is taking inputs

  • 0

i have mvc application in that i have one form which is taking inputs and when i click on submit it is updating values into database .

View code: 
@model Mapping.Models.SecurityIdentifierMappingViewModel
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Mapping</legend>
        <div class="editor-label">
            @Html.Label("Pricing SecurityID")
        </div>
        <div class="editor-field">
            @Html.HiddenFor(model => model.MappingControls.Id)
            @Html.DropDownListFor(model => model.MappingControls.PricingSecurityID,
         new SelectList(Model.PricingSecurities, "Value", "Text"),
         "Select SecurityID"
            )
            @Html.ValidationMessageFor(model => model.MappingControls.PricingSecurityID)
        </div>
        <div class="editor-label">
            @Html.Label("CUSIP ID")
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.MappingControls.CUSIP,
         new SelectList(Model.CUSIPs, "Value", "Text"),
            "Select CUSIP"
            )
            @Html.ValidationMessageFor(model => model.MappingControls.CUSIP)
        </div>

        <div class="editor-label">
            @Html.Label("Calculation")
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.MappingControls.Calculation)
            @Html.ValidationMessageFor(model => model.MappingControls.Calculation)
        </div>
        <p>
            <input type="submit" value="Insert" />
        </p>
    </fieldset>
}

on same page i have a webgrid I need to change text of submit button to Update when I clicked on webgrid’s edit button.
i’m newbie.

Webgrid code
    @model IEnumerable<Mapping.Models.SecurityIdentifierMapping>
    @{
        ViewBag.Title = "Mapping";
        WebGrid grid = null;
        if (Model.Count() > 0)
        {
            grid = new WebGrid(source: Model,
                                    defaultSort: "Id",
                                    canPage: true,
                                    canSort: true,
                                    rowsPerPage: 10);
        }
    }
    <h3>
        Mapping Web Grid</h3>
    @if (grid != null)
    {
        @grid.GetHtml(
                    tableStyle: "grid",
                    headerStyle: "head",
                    alternatingRowStyle: "alt",
                    columns: grid.Columns(
                                                grid.Column("", header: null, format: @<text>@Html.ActionLink("Edit", "Index", new { uid = (int)item.id, userAction = "Edit" })
        @Html.ActionLink("Delete", "Index", new { uid = (int)item.id, userAction="Delete" }, new { @class = "Delete" })</text>),
                                                grid.Column("PricingSecurityID"),
                                                grid.Column("CUSIP"),
                                                grid.Column("Calculation")
                                              )

                    )
    }
    <script type="text/javascript">
        $(function () {
            $(".Delete").click(function () {
                if (confirm("Do you want to delete?")) {
                    var href = $(".Delete").attr('href');
                    href = href + "?userAction=Delete";
                    window.location.href = href;
                    return true;
                }
                return false;
            });
        });
    </script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:07:30+00:00Added an answer on June 2, 2026 at 3:07 am

    You could give your submit button an id:

    <input id="btn-submit" type="submit" value="Insert" />
    

    also apply your Edit anchor a class:

    grid.Column(
        "", 
        header: null, 
        format: 
            @<text>
                @Html.ActionLink(
                    "Edit", 
                    "Index", 
                    new { uid = (int)item.id, userAction = "Edit" }, 
                    new { @class = "edit" }
                )
                @Html.ActionLink(
                    "Delete", 
                    "Index", 
                    new { uid = (int)item.id, userAction="Delete" }, 
                    new { @class = "Delete" }
                )
            </text>
        )
    

    and then subscribe to the click event of an edit link:

    $(function() {
        ...
        $('.edit').click(function() {
            $('#btn-submit').val('Update');
            ...
        });
    });
    

    Now since your Edit anchor seems to be calling a different action on the server and the entire page will probably be reloaded unless you are using AJAX, usnig javascript to set the submit button text is probably not a good idea. In this case the correct way to handle it would be to have the Edit controller action set some property on your view model which will indicate that we are in edit mode and allow to set a condition on the submit button text.

    Something like this:

    <input type="submit" value="@(Model.IsEditing ? "Update" : "Insert")" />
    

    Up to you to set the IsEditing property on your view model to true in the Edit action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have mvc 3 application in which i'm having one input form on Index.cshtml
I have an ASP.NET MVC application that has one part where I dont really
I have a spring mvc application that I have broken up into separate maven
I have created a mvc3 application. Currently saving submit form value into Session as
I have a form in my asp.net mvc(C#) application which handles some dynamic controls.
I have an MVC application that needs to login and verify a user against
I have an mvc application that has been coded to use Windows authentication and
I have an MVC application view that is generating quite a large HTML table
I have an Asp.Net MVC application that works in the vs.net development web server.
I have a ASP.NET MVC application that runs in both IIS 6 and 7.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.