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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:37:28+00:00 2026-05-28T18:37:28+00:00

I have a partial view which has dual list boxes and four buttons; exactly

  • 0

I have a partial view which has dual list boxes and four buttons; exactly like this
http://www.meadmiracle.com/dlb/DLBPlugin.aspx

Now I want to reuse this partial view all throughout the site and every time a user clicks on the buttons to move things in and out of the list, I want this to be persisted in the database via Ajax, I am making an Ajax call using JQuery; this poses a difficulty because the URL of the Ajax call will be different based on the controller that is responding to the call!

$.ajax({
        type: "POST",
        url: '@Url.Action("######HOW TO FIGRE OUT WHICH CONTROLLER #######")',
        success: function (data) {
    //Show some message to the user
        }
    });

Now how do I determine the URL? it will be dynamic, it will be based on the controller that is responding to the initial Index page.

e.g.: if I am in the Cities or Towns page, the user moves Cities and Towns to the list boxes, how do I know it’s the CityController ajax action or the TownController ajax action, how would we know this in the partial view where to post for the ajax call?

  • 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-28T18:37:29+00:00Added an answer on May 28, 2026 at 6:37 pm

    Have your PartialView use a Model which has some properties which define the URL to be called, then the View calling the partial view passes this model, so that your AJAX knows which View to call

    e.g.

    The ViewModel

    public class DualListBoxViewModel {
       public string Controller { get; set; }
       public string Action { get; set; }      
    }
    

    The Partial View

    @model DualListBoxViewModel 
    $.ajax({
            type: "POST",
            url: '@Url.Action(model.Controller, model.Action)',
            success: function (data) {
        //Show some message to the user
            }
        });
    

    The View calling the PartialView

    @{ Html.RenderPartial("DualListBoxWithAjax", new DualListBoxViewModel { Controller = "Town", Action = "UpdateListBox" } ); }

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

Sidebar

Related Questions

I have a partial view that has something like this <%= Html.DropDownListFor(m => m.SelectedProductName,
I am using ASP.Net MVC. I have a partial view which has a form
So right now I have a partial view that just has a list of
not sure how to word this correctly.. so i have a view which has
I have an asp.net view which has two partial views. One for edit information
I have a _layout page which has a login box (partial view) and that
I have a strong typed view model and a MetaData partial class which has
I have this in my partial view: <tr> <% for (int currentDay = 0;
I'm using MVC2 with VS2010 I have a view that has two partial views
I have a partial view that has a create button on it however it

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.