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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:30:47+00:00 2026-05-13T20:30:47+00:00

ASP.NET MVC I have one page Index.aspx where I’m loading two usercontrols into divs.

  • 0

ASP.NET MVC

I have one page Index.aspx where I’m loading two usercontrols into divs. This is working fine. For the moment the usercontrols just shows data and thats working fine. But now I want to add a delete function in the usercontrols and then refresh the div in the Index.aspx page. Is this possible?

Index.aspx

<!-- Panel One -->
<div id="panel1">
    <img src="/Content/ajax-loader.gif" alt="Loading..." />
</div>

<script type="text/javascript">
    $('#panel1').load('../Reports/ReportOne')
</script>

<!-- Panel Two -->
<div id="panel2">
    <img src="/Content/ajax-loader.gif" alt="Loading..." />
</div>

<script type="text/javascript">
    $('#panel2').load('../Reports/ReportTwo')
</script>

ReportOne.ascx and ReportTwo

Just listing some data with a foreach. Here I want to add a deletebutton for each item in the lists.

  • 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-05-13T20:30:48+00:00Added an answer on May 13, 2026 at 8:30 pm

    Make your “delete” action into something like this:

        [AcceptVerbs(HttpVerbs.Post), ValidateAntiForgeryToken]
        public ActionResult Delete(int id) {
            try {
                // do what ever here in deleting the record etc
                // ...
    
                return null;
            } catch (Exception ex) {
                TempData[TempDataKeys.ErrorMessage] = "Error in deleting: " + ex.Message;
                return RedirectToAction("List");
            }
        }
    

    In you ascx/aspx, create a jQuery method to wrap your ajax call to the controller:

    function deleteRecord(recordId) {
        if (confirm("Are you sure that you want to delete this record?")) {
            var token = $("input[name='__RequestVerificationToken']")[0].value;
            url = '<%= Url.Action("Delete", "MyController") %>';
    
            $.post(
               url, 
               { id: recordId, __RequestVerificationToken: token }, 
               function(data) { 
                   if (!data == "") {
                       // success - reload/refresh panel control
                       $('#panel1').load('../Reports/ReportOne');
                   } else {
                       // failed - handle error
                   }  
               }
            );
        }
    }
    

    You will need to put your AntiForgeryToken appropriately so the script can access it – you only need 1 for the whole page. Your delete link should then call to the javascript, instead of to the action in the controller directly:

    <a href="javascript:deleteRecord('<%=recordId%>');">Delete</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one asp.net page. I want to add this page to asp.net mvc
I am working with an ASP.NET MVC application. I have one master page having
I have two ASP.NET MVC web applications. One of them logs unhandled exceptions to
I have an ASP.Net-MVC application that is mostly complete. However, I have one page
I have an ASP.NET MVC web app and on one page I wish to
I have a simple ASP.NET MVC application, like movie sample. In the list.aspx page
I have one question; In my ASP.NET MVC web application have to do certain
i need to have one project on asp.net mvc 1 but i want to
I have got one weird issue. I am working on an asp .net mvc
I'm building an ASP.Net MVC website. Rather than have everything in one project, I've

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.