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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:51:35+00:00 2026-05-26T04:51:35+00:00

I’m having issues posting a model to a controller action using the AJAX helper.

  • 0

I’m having issues posting a model to a controller action using the AJAX helper. The controller action doesn’t get hit at all.

Code:

View:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ServiceNumberModel>" %>

<div id="ServiceNumberPanel">
    <h1>
        Based on your location we offer different plans</h1>
    <% using (Ajax.BeginForm("AvailablePlans", "ServiceCheck", new AjaxOptions { UpdateTargetId = "AdslPlansPanel", HttpMethod = "Post" } ))
       { %>
            <%=Html.ValidationSummary(true)%>
            Your Phone Number:
            <%=Html.TextBoxFor(m => m.HomePhoneNumber)%><br />
            <%=Html.CheckBoxFor(m => m.BundleWithHomePhone)%>Bundle with Home Phone? <br/>
            <input id="CheckServiceAvailabilityButton" type="submit" value="Check"/>
    <% } %>
</div>

Model:

using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace ServiceCheck
{
    public class ServiceNumberModel
    {
        [Required(ErrorMessage = "Please enter your phone number.")]
        [RegularExpression(@"^[0]\d{9}$", ErrorMessage = "Please enter your phone number, including the area code")]
        [DisplayName("Phone Number:")]
        public string HomePhoneNumber { get; set; }


        public bool BundleWithHomePhone { get; set; }
    }
}

Controller:

 [HttpPost]
        public ActionResult AvailablePlans(ServiceNumberModel serviceNumberModel)
        {
            if (serviceNumberModel.BundleWithHomePhone)
                return ReturnAvailableBundledPlans(serviceNumberModel);

            return View("Index");
        }

Generated HTML:

<div id="ServiceNumberPanel">
    <h1>
        Based on your location we offer different plans</h1>
    <form action="/ServiceCheck/AvailablePlans" data-ajax="true" data-ajax-method="Post" data-ajax-mode="replace" data-ajax-update="#AdslPlansPanel" id="form0" method="post">
            Your Phone Number:
            <input data-val="true" data-val-regex="Please enter your phone number, including the area code" data-val-regex-pattern="^[0]\d{9}$" data-val-required="Please enter your phone number." id="HomePhoneNumber" name="HomePhoneNumber" type="text" value="" /><br />
            <input data-val="true" data-val-required="The BundleWithHomePhone field is required." id="BundleWithHomePhone" name="BundleWithHomePhone" type="checkbox" value="true" /><input name="BundleWithHomePhone" type="hidden" value="false" />Bundle with Home Phone? <br/>

            <input id="CheckServiceAvailabilityButton" type="submit" value="Check"/>
    </form>
</div>

Behaviour:
When I click on submit, I get ‘Resource cannot be found error’:

The resource cannot be found. Description: HTTP 404. The resource you
are looking for (or one of its dependencies) could have been removed,
had its name changed, or is temporarily unavailable. Please review
the following URL and make sure that it is spelled correctly.

Requested URL: /ServiceCheck

Interestingly when I look at the source using firebug, I cannot see the form tags:

<div class="ExistingContent">
<h1>ServiceCheck</h1>
<div id="ServiceNumberPanel">
<div id="ServiceNumberPanel">
<h1> Based on your location we offer different plans</h1>
Your Phone Number:
<input id="HomePhoneNumber" type="text" value="" name="HomePhoneNumber" data-val-required="Please enter your phone number." data-val-regex-pattern="^[0]\d{9}$" data-val-regex="Please enter your phone number, including the area code" data-val="true">
<br>
<input id="BundleWithHomePhone" type="checkbox" value="true" name="BundleWithHomePhone" data-val-required="The BundleWithHomePhone field is required." data-val="true">
<input type="hidden" value="false" name="BundleWithHomePhone">
Bundle with Home Phone?
<br>
<input id="CheckServiceAvailabilityButton" type="submit" value="Check">
</div>
<div id="Div1">
</div>
</div>

Also, if I change the view to use the HTML helper it hits the controller without issue:

<div id="Div1">
    <h1>
        Based on your location we offer different plans</h1>
    <% using (Html.BeginForm("AvailablePlans", "ServiceCheck"))
       { %>
            <%=Html.ValidationSummary(true)%>
            Your Phone Number:
            <%=Html.TextBoxFor(m => m.HomePhoneNumber)%><br />
            <%=Html.CheckBoxFor(m => m.BundleWithHomePhone)%>Bundle with Home Phone? <br/>
            <input id="Submit1" type="submit" value="Check"/>
    <% } %>
</div>

Please help!!!

  • 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-26T04:51:35+00:00Added an answer on May 26, 2026 at 4:51 am

    I managed to find the issue.

    In the master page I was using, which is shared across a number of applications, someone had added a rouge form:

    <body>
        <form id="form1" runat="server">
        <uc1:header id="Header1" runat="server" />
        <div class="ExistingContent">
            <asp:contentplaceholder id="MainContent" runat="server" />
        </div>
        <uc2:footer id="Footer1" runat="server" />
        </form>
    </body>
    

    This meant that I was trying to submit a form from within a form and the framework was defaulting to the parent.

    Once removed, everything began to work as expected.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from

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.