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 9168811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:43:15+00:00 2026-06-17T15:43:15+00:00

I have a button called in my view like this one <form> <div class=field>

  • 0

I have a button called in my view like this one

<form>
    <div class="field">
        <label for="product-name">Product Name</label><br />
        @Html.TextBoxFor(x=> x.Name, new {id="product-name",required="required"}) <br />
        <span class="helper">Give your product a name.</span>
        @ViewBag.mm
    </div>
    <div class="field">
        <label for="product-variety">Product Variety</label><br />
        <input id="product-variety" type="text" /><br />
        <span class="helper">Optionally, give your product a variety.</span>
    </div>
    <div class="field">
        <label for="product-description">Description</label><br />
        <input id="product-description" type="text" /><br />
        <span class="helper">Add an optional description to help identify your product.</span>
    </div>
    <div class="field">
        <label for="product-comments">Comments</label><br />
        <textarea id="product-comments"></textarea><br />
        <span class="helper">Add any further information or comments relating to this product.</span>
    </div>
    <input id="product-save-return" type="submit" value="Add Product and Return to Products" class="green-button" /> <input id="product-save-associate" type="button" value="Add Product and Associate with Sites" class="green-button" /> <input id="file-cancel" type="button" value="Cancel" class="green-button" />

and in the controller I have a function like this

[HttpPost]
public ActionResult Add(Product product)
{
    SupplierContext db = new SupplierContext();
    Response.Write("Inside");
    ViewBag.mm = "xyz";
    if (ModelState.IsValid)
    {
        product.Key = Guid.NewGuid();
        product.Type = ProductType.Chemical;
        product.Status = EntityStatus.Default;
        db.Products.Add(product);
        db.SaveChanges();
        return RedirectToAction("Index");
    }

    return View(product);
}

but when i click the button, the function in the controller doesn’t work.

  • 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-17T15:43:15+00:00Added an answer on June 17, 2026 at 3:43 pm

    Is your button within a form/action? In Razor it would simply just be a case of adding your form elements within the following syntax:

    @using (Html.BeginForm())
    {
        <div class="field">
            <label for="product-name">Product Name</label><br />
            @Html.TextBoxFor(x=> x.Name, new {id="product-name",required="required"}) <br />
            <span class="helper">Give your product a name.</span>
            @ViewBag.mm
        </div>
        <div class="field">
            <label for="product-variety">Product Variety</label><br />
            <input id="product-variety" type="text" /><br />
            <span class="helper">Optionally, give your product a variety.</span>
        </div>
        <div class="field">
            <label for="product-description">Description</label><br />
            <input id="product-description" type="text" /><br />
            <span class="helper">Add an optional description to help identify your product.</span>
        </div>
        <div class="field">
            <label for="product-comments">Comments</label><br />
            <textarea id="product-comments"></textarea><br />
            <span class="helper">Add any further information or comments relating to this product.</span>
        </div>
        <input id="product-save-associate" type="button" value="Add Product and Associate with Sites" class="green-button" />  <input id="file-cancel" type="button" value="Cancel" class="green-button" />
       <input id="product-save-return" type="submit" value="Add Product and Return to Products" class="green-button" />
    }
    

    This could be why it is not picking up the function in the controller. You could do this in javscript too with an AJAX post…

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

Sidebar

Related Questions

I have a view controller called vc0 which is presented like this: [self presentViewController:
Assume we have a single Windows form with a button called SimpleButton1. The following
I have created my own button class called custom_btn. I created it on the
I have a class called Mouse (tracking button states in a game). I want
I have this method that gets called when i press a button and removes
I have a simple form based off a model called Visitor. I'd like to
I've added a button on cell of my table view like this- UIButton* checkBoxBtn
I have a button in a Nib based view which does not behave like
I have one page called myimage.aspx which creates random captcha image , <form id=form1
I have a backbone view - which when called presents a form $('#add-offer').click(function() {

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.