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

  • Home
  • SEARCH
  • 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 297841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:40:35+00:00 2026-05-12T06:40:35+00:00

I try to creat list for detail view. then put a search text box

  • 0

I try to creat list for detail view. then put a search text box on the top of the list. Hope the search result will replace the list partially.

My control code like:

public ActionResult Index(int? page)
{
  Repository repository = new Repository();
  var listitems= repository.FindAllItems();
  return View(registry_page);
}

public ActionResult Search(string keyword)
{
  try
    {
     Repository repository = new Repository();     
     var listitems = repository.FindItemsByKeyWord(keyword);           
     return View("Index", registries);
    }
  catch
  {
    return View("Index");
   }
}

My View code like:

<script src="<%= Url.Content("~/Scripts/MicrosoftAjax.js") %>" type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.js") %>" type="text/javascript"></script>

<% using (Ajax.BeginForm("Search", new AjaxOptions { UpdateTargetId = "MyList" }))
   { %>
<p>
    Search:
    <input id="keyword" name="keyword" type="text" />
    <input type="submit" value="Go" />
</p>
<% } %>

<div id="MyList">
 <table idth="780px">
    ...

    <% foreach (var item in Model)
      { %>
      <tr>
      ...
      </tr>
    <% } %>
 </table>
</div>

When I submit the ajax form, it did reach the right action Searcn and I did get the right result from repository, but the list in the view wasn’t replaced with the new result.

If I change search action like:

public ActionResult Search(string keyword)
{
 string teststring = "<div>This is a test string to replace the list</div>";
 return Content(teststring);
}

The list wil be replace by the test string.
How to fix this problem?

  • 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-12T06:40:36+00:00Added an answer on May 12, 2026 at 6:40 am

    You can pull MyList out into a Partial view, MyPartialList.ascx

    Your search actionresult should then return this partial view, something like this:

    public ActionResult Search(string keyword)
    {
         Repository repository = new Repository();     
         var listitems = repository.FindItemsByKeyWord(keyword);           
         return PartialView("MyPartialList", listitems);
    }
    

    In the index view, render the initial list like this:

    <div id="MyList">
      <% Html.RenderPartial("MyPartialList",Model); %>
    </div>
    

    Your partial, MyPartialList.ascx would look like this:

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Item>>" %>
    <table ..>
    <% foreach(var item in Model){%>
      // print it out
    <%}%>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm try to create a new list object. I set the new object to
In the Demo WCF, I am having an error when try to creat class
I'm a novice using VB6 to try and create a basic text file program.
I have a master-detail relationship between 2 classes. The master class will contain a
This is my 1st question so i will try to b as precise as
I try to list file details using FtpWebRequest but very frequently it fails with
I have built a RSS reader that switches to a detail view when a
I have a list view populated by an adapter reading from SQLite database. When
I have a table view that's showing a list of bank transactions. When I
I try for 2 days to make a link between a list and a

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.