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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:59:48+00:00 2026-05-23T03:59:48+00:00

I’m currently working with MVC 1.0 and have never worked with AJAX before and

  • 0

I’m currently working with MVC 1.0 and have never worked with AJAX before and only have limited experience (started a little more than a week ago) with ASP.Net MVC. I’m trying to setup a table (that’s built / is in a partial view) that’s populated with information from a db that allows a user to quickly add pr remove records into or from the db right from the table. I’m trying to use AJAX to get this done because there is a lot of other information on the rest of the page that I don’t want to have to reload. Here’s a quick template.

row1: (text box) Add

row2: Name1 Remove

row3: Name2 Remove

So when a user wants to, they can enter a name into the (text box) hit Add and an action in the controller will add the entered name into the database and reload the partial view with the most up to date information.

So far I have been able to get the action method to be called, and add the record into the database. The problem is that it does not reload JUST the partial-view. It instead loads the partial-view as a whole new page and it’s content is the only one that displays. (Instead of staying at /Project/Details/5, the page loads /Project/MembersDisplay)

In my master page I have:

<script src="<%= Links.Scripts.jquery_1_3_2_min_js %>" type="text/javascript"></script>
<script src="<%= Links.Scripts.MicrosoftAjax_js %>" type="text/javascript"></script>
<script src="<%= Links.Scripts.MicrosoftMvcAjax_js %>" type="text/javascript"></script>

In the controller I have:

[AcceptVerbs(HttpVerbs.Post)]
    public virtual ActionResult AddMember(FormCollection form)
    {
        MemberRepository repo = new MemberRepository();
        Member m = new Member();
        m.Id = Convert.ToInt32(form["Id"]);
        m.Name = form["name"];

        try{
            repo.addMember(m);
            repo.save();
        }
        catch{
            return View();
        }

        // Make a new IList of All Members in this current 
        //IList<Member> mems = (new PRDataContext()).Members_GetMembersById(m.Id).ToList<Member>();

       return View("MembersDisplay", members);
    }

The Partial view is

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<Application.Models.Member>>" %>
<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoffMvcAjax.js" type="text/javascript"></script>
<table>
    <% if (Model.Count() > 0) { %>
        <% foreach (var p in ViewData.Model) { %>
    <tr>
        <td><%= Html.Encode(p.Name) %></td>
        <td><%= Ajax.ActionLink("Delete", "AjaxDelete", new { p.Id, p.Name }, new AjaxOptions { Confirm = "Delete?", HttpMethod = "AjaxDelete", UpdateTargetId = "results" })%></td>
    </tr>
        <% } %>
    <% } else { %>
    <tr>
        <td><b>There are no Members.</b></td>
    </tr>
    <% } %>
</table>

In the controller, I tried adding if(Request.IsAjaxRequest()==true) the branch never executed. I’m not sure if ajax isn’t loading, or what I’m doing wrong.

EDIT – Added missing code

Here’s the details portion that uses the partial view:

<table>
<% Ajax.BeginForm("AddMember", "Project", new AjaxOptions { UpdateTargetId = "results", InsertionMode=InsertionMode.Replace}) { %>
<tr>
    <td align="left" colspan="2" style="background-color:#93B6E0;"><font style="color:#fff;"><b>Members</b></font></td>
</tr>
<tr>
    <td width="80%">
        <input type="hidden" name="prjId" value="<%= Html.Encode(Model.Id) %>" /><input type="text" name="name" style="width:120px;" />
    </td>
    <td width="20%">
        <input type="submit" value="Add" />
    </td>
</tr>
<% } %>
<tr>
    <td colspan="2">
        <div  id="results"><% Html.RenderPartial(MVC.Members.Views.MembersDisplay, Model.Members.ToList<Member>()); %></div>
    </td>
</tr>

  • 1 1 Answer
  • 6 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-23T03:59:49+00:00Added an answer on May 23, 2026 at 3:59 am

    I upgraded to MVC 2.0 as @RailRhoad suggested.

    Then I moved the partial view to an area and has to change the path links to the .js files to be more explicit (T4MVC wasn’t rendering the correct paths). Instead of

    <script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>

    or

    <script src="<%= Links.Scripts.MicrosoftAjax_js %>" type="text/javascript"></script>

    I had to do

    <script src="../../../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>

    Also, the action in the controller worked as @jim suggested by

    return PartialView(MVC.ProjectDash.Project.Views.MembersDisplay, members);
    

    Also, I removed the “InsertionMode=…” from

    <% Ajax.BeginForm("AddMember", "Project", new AjaxOptions { UpdateTargetId = "results", InsertionMode=InsertionMode.Replace}) { %>
    

    The biggest issue was the javascript files were not be linked up and referenced correctly. Once that was fixed, the other things quickly feel into place.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.