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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:42:53+00:00 2026-06-15T20:42:53+00:00

I have a Partial View in my main View listing a number of items.

  • 0

I have a Partial View in my main View listing a number of items.
Razor has correctly produced this partial view for me and has inserted action links (using the @Html.ActionLink command) pointing at an action at a controller and sending in the correct id.
All that works but I wish it to stay like that and not have to return anything!

Right now I am forced to send back something (Content, View, Redirect etc) which changes the main view and I don’t want that.

All I want to do is to take action on the server and leave it at that.
What else can I do?

Thanks

@model IEnumerable<PopupForm.Models.BOExplorerItem>

<h3>Explorer (partial)<br />
    There are @Model.Count() explorer items.
</h3>

<ul class="ulexplorer">

    @foreach (var item in Model)
    {
        <li>
            <div class="boitem">
                <h5>@item.FullName [<i> @item.Code </i>]</h5>
                <span>Level: @item.Level</span>
                @Html.ActionLink("Select", "SelectEntity", "Explorer", new { code = @item.Code }, null)
            </div>
        </li>
    }

</ul>
  • 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-15T20:42:54+00:00Added an answer on June 15, 2026 at 8:42 pm

    What you can do is listen to the click event of link and make an ajax call instead of the normal redirect behaviour. Let the ajax call intitate what code you want to execute.

    So change your link like this to apply a css class to our links so that we can use it as our jQuery element selector.

    @Html.ActionLink("Select", "SelectEntity", "Explorer",
                                new { code = @item.Code }, new { @class="ajaxLink"})
    

    Now some javascript to bypass the click event

    $(function(){
      $("a.ajaxLink").click(function(e){
        var _item=$(this);
        e.preventDefault();  //prevent default behaviour
        $.get(_item.attr("href");
      });
    });
    

    If you want your Action method to execute normal (return View /Other content) on normal non-ajaxified request, you may add an if condition checking to see whether the request is ajax or not

    public ActionResult SelectEntity()
    {
      if (Request.IsAjaxRequest())
      {
        //Execute your method and return a Json result to keep the compiler happy.
        return Json(new {Status="Success"},JsonRequestBehavior.AllowGet);
      }
      else
      {
         //Return the normal view,
         return View();
      } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main view and the URL for this view has a Action/Controller/Area
I have a partial view that has something like this <%= Html.DropDownListFor(m => m.SelectedProductName,
I have a partial view that has a number of Div's, each are set
I have something like this: Main view: @model AuthorViewModel @using (Html.BeginForm(Action, Controller, FormMethod.Post, new
I have a partial view that uses a Telerik MVC Grid, and it has
So right now I have a partial view that just has a list of
I have a main view which has master layout contains all javascripts, ie jQuery
I have a view that has a partial view in it, everything works fine,
I have my main view like this: <%@ Page Title= Language=C# MasterPageFile=~/Views/Shared/Site.Master Inherits=System.Web.Mvc.ViewPage %>
'm using ASP.NET MVC 3 with Razor views. I have a partial view which

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.