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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:05:32+00:00 2026-05-14T03:05:32+00:00

I have a View that renders something like this: Item 1 and Item 2

  • 0

I have a View that renders something like this:

alt text

“Item 1” and “Item 2” are <tr> elements from a table.

After the user change “Value 1” or “Value 2” I would like to call a Controller and put the result (some HTML snippet) in the div marked as “Result of…“.

I have some vague notions of JQuery. I know how to bind to the onchange event of the Select element, and call the $.ajax() function, for example.

But I wonder if this can be achieved in a more efficient way in ASP.NET MVC2.

  • 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-14T03:05:32+00:00Added an answer on May 14, 2026 at 3:05 am

    Here is an example of the method I use with great success:

    In the View:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Namespace.Stuff>>" %>
    
    <asp:Content ID="Content3" ContentPlaceHolderID="head" runat="server">
        <script type="text/javascript">
         $(document).ready(function(){
            $("#optionsForm").submit(function() {
                $("#loading").dialog('open');
                $.ajax({
                    type: $("#optionsForm").attr("method"),
                    url: $("#optionsForm").attr("action"),
                    data: $("#optionsForm").serialize(),
                    success: function(data, textStatus, XMLHttpRequest) {
                        $("#reports").html(data); //replace the reports html.
                        $("#loading").dialog('close'); //hide loading dialog.
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        $("#loading").dialog('close'); //hide loading dialog.
                        alert("Yikers! The AJAX form post didn't quite go as planned...");
                    }
                });
                return false; //prevent default form action
            });
        });
        </script>
    </asp:Content>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    
        <div id="someContent">
            <% using (Html.BeginForm("Index", "Reports", FormMethod.Post, new{ id = "optionsForm" }))
              { %>
    
              <fieldset class="fieldSet">
                <legend>Date Range</legend>
                From: <input type="text" id="startDate" name="startDate" value="<%=ViewData["StartDate"] %>" />
                To: <input type="text" id="endDate" name="endDate" value="<%=ViewData["EndDate"] %>" />
                <input type="submit" value="submit" />
              </fieldset>
    
            <%} %>
        </div>
    
        <div id="reports">
            <%Html.RenderPartial("ajaxStuff", ViewData.Model); %>
        </div>
    
        <div id="loading" title="Loading..." ></div>
    </asp:Content>
    

    In the Controller:

    public ActionResult Index(string startDate, string endDate)
    {
        var returnData = DoSomeStuff();
    
        if (Request.IsAjaxRequest()) return View("ajaxStuff", returnData);
        return View(returnData);
    }
    

    The above code outlines the basic strategy. You will, of course want to tweak it for multiple partials and multiple forms.

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

Sidebar

Related Questions

I have a view user control that can post form. This control can be
I have a view that has a list of jobs in it, with data
I have a view that I want to add some custom drawing to. I
I have a View that can vary significantly, depending on the 'mode' a particular
I have a view that is joining two tables and ordering by the first
Image i have a view that is cached with the OutputCache attribute but i
How does your employer limit/prevent pirating of its products? Some have the view that
I have a list view that is periodically updated (every 60 seconds). It was
I have a view using a master page that contains some javascript that needs
We have a View (call it X) that is the base view called by

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.