Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

320
Views
How to ask user if he wants to insert a duplicated record in a list

I have an input form (only one field, Serial Number) a Button to submit the form and a list to show all the Serial Numbers:

Main page of my application

The way it works is, I inform a serial number and click 'Add to List' and the controller will add that Serial Number to the list and return to Index.

Here is my controller:

[HttpPost]
public ActionResult Create(Product productFromView)
{
    try
    {
        Product product = new Product();
        product.Id = StaticProducts.Products.Count + 1;
        product.SerialNumber = productFromView.SerialNumber;

        //check if serial number has been added to the list already
        if (Products.Any(s => s.SerialNumber == product.SerialNumber))
        {
            //serial number has been added to the list already
            //return to the view with a pop up message asking if the user wants to insert that serialnumber anyway
            //if user replies 'yes': add serial number to the list
            //if user replies 'no': return to index view
        }
        else
        {
            Products.Add(product);
        }

        return RedirectToAction(nameof(Index));
    }
    catch
    {
        return View(productFromView);
    }
}

Now I want to check if the serial number has been added to the list, if so, show a message to the user asking if he wants to insert the serial number again. And only if user replies 'yes' we add the serial number to the list.

I've already tried a few different things, but I still couldn't find out a proper way of doing that, I believe I will have to use JavaScript, but I still can't figure out how am I supposed to do that, like, what do I do in the controller to return to the view with a pop-up message, and if the user replies yes how can I return to the controller to add the serial number to the list.

Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!