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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:53:50+00:00 2026-06-09T21:53:50+00:00

i have the following code that opens a dialogue with a View. $(‘.bulkEditlink’).click(function ()

  • 0

i have the following code that opens a dialogue with a View.

$('.bulkEditlink').click(function () {
    var f = $('td:first', $(this).parents('tr')).text();
    var r = tableCols().toString();
    loadBulkEdit(f, r); //loadBulkEdit is defined on RoleCompare View.
});

–load view with get

function loadBulkEdit(f,r) {
        var  $urlpath = "@Url.RouteUrl(new { area = "Admin", controller = "Role", action = "RoleEntitlementEdit"})";
        $.ajax({
            url: $urlpath,
            type: 'GET',
            data:  { 
                        funct: f, 
                        roleName: r, 
                        access: 'access' 
                    },
            OnFailure: "alert('error')",
            success: function (data) {
                $("#ajax-content").html(data);
                loadAccess();
            }
        });
} //end loadBulkEdit

–Dialogue box. On save, calls SaveRoleEntitlement action method (Ajax.BeginForm options defined on view

function loadAccess(xhr, status) {
        $('#ajax-content').dialog({
            modal: true,
            width: 370,
            title: $('#ajax-content legend').text(),
            buttons: {
                "Save": function () {
                    $('#ajax-content form').submit();
                   $(this).dialog('destroy').html('');
                },
                "Cancel": function () {
                    $(this).dialog('destroy').html('');
                }
            }
        });
    } //end popup

–Controller action

public JsonResult SaveRoleEntitlement(RoleEntitlementEidtModel model)
        {
            try
            {

                string strPackageName = model.RoleName;
                string strFebSecID = User.Identity.Name;
                string strKeyValue = "";
                string strFunction = model.Function;
                string strAccessLevel = model.AccessLevel;

                PatService.EditEntitlement(strFebSecID, strPackageName, strFunction, strAccessLevel, strKeyValue);
                return Json(new { Error = string.Empty });
            }
            catch (Exception ex)
            {
                return Json(new { Error = ex.Message });
            }
        }

This works fine except that I’m struggling to add 1. Error handling on Save. I want to show error message to the user if there are any exceptions 2. Progress bar or a sort of ‘wait’ message while the method executes. Hope someone will help me.

Thanks.

  • 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-09T21:53:51+00:00Added an answer on June 9, 2026 at 9:53 pm

    It would really depend on how/where you want to show the error message. The first possibility is to return JSON in case of an error (as you currently do) and then subscribe to the OnSuccess handler in your Ajax.BeginForm to handle this case:

    @using (Ajax.BeginForm("SaveRoleEntitlement", "Role", new { area = "Admin" }, new AjaxOptions { OnSuccess = "saveRoleEntitlementSuccess" }))
    {
        ...
    }
    

    and then define this success callback:

    function saveRoleEntitlementSuccess(result) {
        if (result.Error && result.Error != '') {
            // there was an error => show it somehow
            alert(result.Error);
        } else {
            // the save was successful => do whatever you need to do in this case
        }
    }
    

    Another possibility if you want to handle validation errors directly on the UI is to return the same partial in case of an error:

    public ActionResult SaveRoleEntitlement(RoleEntitlementEidtModel model)
    {
        if (!ModelState.IsValid)
        {
            // there was a validation error => redisplay the partial form
            // so that fields appear in red
            return PartialView("RoleEntitlementEdit", model);
        }
        try
        {
            string strPackageName = model.RoleName;
            string strFebSecID = User.Identity.Name;
            string strKeyValue = "";
            string strFunction = model.Function;
            string strAccessLevel = model.AccessLevel;
    
            PatService.EditEntitlement(strFebSecID, strPackageName, strFunction, strAccessLevel, strKeyValue);
            return Json(new { success = true });
        }
        catch (Exception ex)
        {
            // we're gonna show this in a ValidationSummary
            ModelState.AddModelError("", ex.Message);
            return PartialView("RoleEntitlementEdit", model);
        }
    }
    

    and your Ajax form:

    @using (Ajax.BeginForm("SaveRoleEntitlement", "Role", new { area = "Admin" }, new AjaxOptions { OnSuccess = "saveRoleEntitlementSuccess" }))
    {
        @Html.ValidationSummary()
        ...
    }
    

    and your saveRoleEntitlementSuccess function this time:

    function saveRoleEntitlementSuccess(result) {
        if (result.success) {
            // the save was successful => do whatever you need to do in this case
        } else {
            // there was an error => in this case the controller action returned
            // a partial that we could use to refresh the form in the DOM:
            $('#ajax-content').html(result);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that opens a new popup window while disabling the
I have the following code that determines if it's the first time the user
I have the following code which works fine: // click on the button $(.btnHeaderSearch).click(function(event)
I have the following code for a button click event. This event should open
I have a unicode filename that I would like to open. The following code:
I have following code that I am compiling in a .NET 4.0 project namespace
I have following code that does not work due to a being a value
I have following code that does not work: I never get to goToFoodDetail .
I have following code snippet that i use to compile class at the run
I have the following code that has @item.ID from razor: <a href=# id=deleteitem(@item.ID)>Delete</a> When

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.