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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:50:12+00:00 2026-06-17T04:50:12+00:00

I have a table with a Ajax.BeginForm on each row. This works good to

  • 0

I have a table with a Ajax.BeginForm on each row. This works good to pass the data to the controller.

However, it wont fire the Request.IsAjaxRequest() on the controller because of the form post(thanx HTX9 for pointing that out!). The real problem is that it returns a partial view instead of updating it in the current view.

Below you can see two fieldsets. The first is the one i want to update and the one below it is the one which sends data to the controller with the Ajax.BeginForm.

With other words: When I choose something in a dropdownlist it updates the table above but it opens it in a new partial view.

I have the unobtrusive ajax js in the _layout view and a similar setup works in an other part of the application from with a post data with a button instead.

<fieldset>
    <legend>Direktbyten</legend>
    <div id="container-grid2">
        @Html.Partial("_RatingList2", Model.Models2)
    </div>
</fieldset>

<fieldset>
    <legend>Omarkerade byten(@ViewBag.DirectCount)</legend>

    <div id="RatingList">
    <table>
        <thead>
            <tr>
                <td>Se hela</td>
                <td>Hyra</td>
                <td>Rum</td>
                <td>Kvm</td>
                <td>Gata</td>
                <td>Område</td>
                <td>Deras prio</td>
                <td>Totaltvärde</td>
                <td>Min prio</td>
            </tr>

        </thead>
        <tbody>
            @foreach (var item in Model.Models1)
            {
                using (Ajax.BeginForm("UpdateRatingListRow", new AjaxOptions { UpdateTargetId = "container-grid2" }))
                { 

                @Html.Hidden("RatingListId", item.RatingListId)
                <tr>
                    <td>@Html.ActionLink("Till annons", "ViewAd", "Ad", new { id = item.CustomerId }, null)
                    </td>
                    <td>@item.Rent</td>
                    <td>@item.Rooms</td>
                    <td>@item.SquareMeters</td>
                    <td>@item.Street</td>
                    <td>@item.Area</td>
                    <td>@item.TheirRating</td>
                    <td>@item.TotalRating</td>
                    <td>
                     @Html.Raw("<div id='" + item.RatingListId + "'>")
                        <select name="SelectedValue" onchange="this.form.submit();">
                            <option value="0"@if (item.MyRating == "00")
                                             {
                                                 @Html.Raw("selected")
                                             }>Ny</option>
                            <option value="10" @if (item.MyRating == "10")
                                               {
                                                   @Html.Raw("selected")
                                               }>Inget intresse</option>
                            <option value="50"@if (item.MyRating == "50")
                                              {
                                                  @Html.Raw("selected")
                                              }>Svagt intressse</option>
                            <option value="60"@if (item.MyRating == "60")
                                              {
                                                  @Html.Raw("selected")
                                              }>Litet intresse-vill ej ha kontakt</option>
                            <option value="70"@if (item.MyRating == "70")
                                              {
                                                  @Html.Raw("selected")
                                              }>Intresserad-Vill ha kontakt</option>
                            <option value="80"@if (item.MyRating == "80")
                                              {
                                                  @Html.Raw("selected")
                                              }>Varit på visning-Vill gå vidare</option>
                            <option value="90"@if (item.MyRating == "90")
                                              {
                                                  @Html.Raw("selected")
                                              }>Intresserad-Vill ha kontakt</option>
                            <option value="100"@if (item.MyRating == "100")
                                               {
                                                   @Html.Raw("selected")
                                               }>Avvaktar värdar</option>
                        </select>@item.MyRating
                        @Html.Raw("</div>")
                    </td>
                </tr>
                }
            }
        </tbody>
    </table>
</div>

</fieldset>

Here is the Controller:

[HttpPost]
public ActionResult UpdateRatingListRow()
{
   if (Request.IsAjaxRequest())
   {
       //Do stuff, it does not hit this part because of the isAjaxRequest().
       return this.PartialView("_RatingList2", myRatingListMarked);
   }
   return this.PartialView("_RatingList2", null);
}

Generated Html:
enter image description here

  • 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-17T04:50:14+00:00Added an answer on June 17, 2026 at 4:50 am

    Here is my “fulhack”(ugly hack in swedish), added a button with each row id and then i call it for submit. Still hoping for a clean solution without having to rewrite a lot of code.

    using (Ajax.BeginForm("UpdateRatingListRow", new AjaxOptions { UpdateTargetId = "container-grid2", OnSuccess = "OnSuccess('" + item.RatingListId + "')" }))
    { 
       <input type="submit" id="@item.RatingListId" style="position: absolute; top: -1000px">
       @Html.Hidden("RatingListId", item.RatingListId)
       <tr>
          <td>@Html.ActionLink("Till annons", "ViewAd", "Ad", new { id = item.CustomerId }, null)</td>
          <td>@item.Rent</td>
          <td>@item.Rooms</td>
          <td>@item.SquareMeters</td>
          <td>@item.Street</td>
          <td>@item.Area</td>
          <td>@item.TheirRating</td>
          <td>@item.TotalRating</td>
          <td>@Html.Raw("<div id='" + item.RatingListId + "'>")
            <select name="SelectedValue" onchange="document.getElementById(@item.RatingListId).click();">
              <option value="0"@if (item.MyRating == "00")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have @Ajax.BeginForm in each row of Table, When I make post request using
I have an table and needed Ajax form for each row so this is
I'm using jQuery to drive my AJAX UI. I have a table of data,
I have this bit of JavaScript... 15 $('.ajax_edit_address').each(function() { 16 $(this).ajaxForm({ 17 target: $(this).parents('table.address').find('tr.address_header').children(':first'),
I have table with ajax paging, i can select any page and view data,
I have a HTML table with a column per row with this html code
So I have a table of data, and I'm getting data back using ajax.
I have a function that searches a database table via ajax. This is the
I have a pager on a table using ajax and I would like each
I have a table which is updated with ajax and after update it if

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.