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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:46:31+00:00 2026-05-25T23:46:31+00:00

I am having some challenges with validation in my ASP.NET MVC3 project when using

  • 0

I am having some challenges with validation in my ASP.NET MVC3 project when using jQuery and AJAX to post back data from a partial view.

Adding validation to the NoteText field within my partial view results in “$(‘#noteAdd’).submit” event failing to trigger and my form posting directly to the controller. Removing the validation results in the expected behaviour.

I was hoping somebody might be able to shed some light over what’s happening here, why it’s happening and my provide some advice on how to resolve the issue and I’ve included my partial, controller, JS and view below.

My Partial

[Bind(Include = "NoteId,NoteText,Date,SourceId,Username,TypeId,ItemId,Processed")]
[MetadataType(typeof(NotePartial_Validation))]
public class NotePartial
{
    public int NoteId { get; set; }
    public string NoteText { get; set; }
    public DateTime? Date { get; set; }
    public int? Source { get; set; }
    public string Username { get; set; }
    public int ItemId { get; set; }
    public int TypeId { get; set; }

    public IEnumerable<NotePartial> ExistingNotes { get; set; }

}
public class NotePartial_Validation
{
    [HiddenInput(DisplayValue = false)]
    public int NoteID { get; set; }

    [Required]
    public string NoteText { get; set; }

    [HiddenInput(DisplayValue = false)]
    public int ItemId { get; set; }

    [HiddenInput(DisplayValue = false)]
    public int TypeId { get; set; }

}

}

My Controller

public class NoteController : Controller
{
    [HttpPost]
    public ActionResult Create(NotePartial model)
    {

        try
        {
            NoteMethods.CreateNote(model.NoteText, SessionManager.Current.ActiveUser.Username, model.ItemId, SessionManager.Current.ActiveUser.Company);

            return Json(new { s = "Success" });
        }
        catch (NoPermissionException)
        {
            return Json(new { s = "No permission" }); 
        }

    }
}

My View

@model EF.NotePartial
@{using (Html.BeginForm("Create", "Note", new { area = "" }, FormMethod.Post, new { id = "noteAdd" }))
{ 

@Html.TextAreaFor(m => m.NoteText, new { @class = "note-input" })  //note-input
@Html.ValidationMessageFor(model => model.NoteText)     

<input type="submit" value="Send" /> 

}}
 <script type="text/javascript">

 $(function () {
    $('#noteAdd').submit(function () {
        $.ajax({
            url: this.action,
            type: this.method,
            data: $(this).serialize(),
            error: function (xhr, ajaxOptions, thrownError) {
                alert('An error occured when processing this request:\r\n\r\n' + thrownError);
            },
            success: function (result) {
                alert(result.s);
            }
        });
        // it is important to return false in order to  
        // cancel the default submission of the form 
        // and perform the AJAX call 
        return false;
    });
  });

  • 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-25T23:46:32+00:00Added an answer on May 25, 2026 at 11:46 pm

    put partial keyword on your class :

    public partial class NotePartial
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using .NET, XSLT to achieve below functionality, however there is some challenges
I'm having some inexplicable behaviour using jQuery 1.4.2, and I'm beginning to think that
Having some problems with getting some ajax script to work. Using this as the
Having some difficulty using a variable within an ajax() function. I know it is
Basically having some trouble with using Hover to hide or show an item. The
im having some difficulty trying to pull out a specific value from a cookie.
LIVE CODE: http://jsfiddle.net/vy4nY/ I'm following this challenge , but I'm having some issues. I'm
Having some trouble getting a JSON feed to load from my site. I'm starting
Having some out-of-memory problems with a 32-bit process in Windows I begun using Performance
Having some issues getting my head around the differences between UTF-8, UTF-16, ASCII and

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.