c# - MVC + How can i alert prompt user before Controller action -
mvc newbie here.
i want user confirmation before controller action (update 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 need prompt user if maxinstances entered zero- job disabled want processs (y/n) if yes update else nothing or redirect edit screen } return redirecttoaction("jobhandler"); } return view(item); }
do need using javascript alert? or there way.
you can onclick event handler:
<input type="submit" onclick="return confirm('are sure wish submit?');" />
you can client-side prompts, because controller code executes on server, of course client can't access.
Comments
Post a Comment