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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:24:25+00:00 2026-06-11T13:24:25+00:00

I have a delete hyperlink shown on the screen: UsersPartial VIEW: <%: Ajax.ActionLink(Delete, Delete,

  • 0

I have a delete hyperlink shown on the screen:

UsersPartial VIEW:

<%: Ajax.ActionLink("Delete", "Delete", new { id = item.UserID }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "tabs-users", InsertionMode = InsertionMode.Replace }, htmlAttributes: new { data_target = "#tabs-users" })%>

This calls a method in my controller

CONTROLLER

    [HttpGet]
    public PartialViewResult Delete(int id)
    {
        userManager.DeleteUser(id);
        ViewBag.Status = string.Format("User deleted ok, id: {0}", id);
        return PartialView("UsersPartial", userManager.GetUsers());
    }

In the above code, I return a PartialView, this works. I would like to also display a message at the top of this view, defined above in ViewBag.Status, but I only want it to show this div once this action is taken.

Also note, that my view I am returning to has is strongly typed:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<LMS.Data.User>>" %>

Lastly, the status message I’d like to display is a div that I created into another partial view so I can show it throughout the site.

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>

<div id="status" class="statusok">
<%: ViewBag.Status %>
</div>

What’s the proper way to do this?

  • 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-11T13:24:27+00:00Added an answer on June 11, 2026 at 1:24 pm

    You cannot return 2 different partial views from a controller action. One approach you might use is to render the first partial to a string and then have your controller action return a JSON result with 2 properties – one containing the HTML partial and the other containing the message to display:

    [HttpDelete]
    public PartialViewResult Delete(int id)
    {
        userManager.DeleteUser(id);
        return Json(new 
        {
            Partial = RenderPartialViewToString("UsersPartial", userManager.GetUsers()),
            StatusMessage = string.Format("User deleted ok, id: {0}", id)
        });
    }
    

    and then:

    <%= Ajax.ActionLink(
        "Delete", 
        "Delete", 
        new { 
            id = item.UserID 
        }, 
        new AjaxOptions { 
            HttpMethod = "DELETE", 
            OnSuccess = "onDelete"
        }, 
        htmlAttributes: new { data_target = "#tabs-users" }
    ) %>
    

    and then write the onDelete callback:

    function onDelete(result) {
        $('#tabs-users').html(result.Partial);
    
        // TODO: instead of alerting display the message wherever you want
        // and using whatever plugin you want to make it look pretty
        alert(result.StatusMessage);
    }
    

    You will also notice that I have used the proper HTTP verb for this task – DELETE. Never use the GET verb to invoke controller actions that are modifying state on your server (such as deleting an entity).

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

Sidebar

Related Questions

I have a delete issue at the moment. We do not have permission to
I have a delete button on a table and a jquery on click eventlistener
I have to delete some elements of my array, but without rearrange array. If
I have a delete form wherein the user will enter the pnum to be
I have to delete all rows of a model with condition fkey_id = 1
I have a delete button on my web site which I want to add
I have a delete button and on clicking cancel on the confirm box, it
I have to delete folder with more than 30000 images. I have '.nomedia' file
I want to have a delete user link in a normal Activerecord table, but
I have a database where most tables have a delete flag for the tables.

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.