MVC + How can i alert prompt user before Controller action

MVC Newbie here.

I want to get User confirmation before controller action (update a record)

my code:

[HttpPost]
    public ActionResult JobHandlerUpdate(int jobScheduleId, JobHandlerList jobHandlerList)
    {
        var updateJobHander = new MainJobHandler();
        var item = updateJobHander.GetById(jobScheduleId);
        if (ModelState.IsValid)
        {
            List<string> days = jobHandlerList.JobProcessDayOfWeek.Split(',').ToList();
            updateJobHander.Update(item, days);
            if(jobHandlerList.MaxInstances == 0)
            {

                // here I need to prompt user if maxInstances entered is Zero- 
                   Job will be disabled want to processs (Y/N) if yes update 
                   else do nothing or redirect to edit screen
            }
            return RedirectToAction("JobHandler");
        }

       return View(item);
    }

Do i need to do using javascript alert? or is there a good way.

Answers


You can probably do with an onClick event handler:

<input type="submit" onclick="return confirm('Are you sure you wish to submit?');" />

You can only do client-side prompts, because your Controller code executes on the server, which of course the client can't access.


Need Your Help

Meteor MongoDB - cant insert _id with _id from API call

mongodb meteor twitch

I am trying to call the TwitchAPI and insert some of the returned data into MongoDB. However, every time I get this error: Error: Meteor requires document _id fields to be non-empty strings or Obje...

Using Omniauth, how can I see the repositories of a user who logs in with Github?

ruby-on-rails-4 omniauth github-api

I've setup Omniauth on my Rails 4 application to allow a user to sign in using Github.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.