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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:46:48+00:00 2026-05-18T05:46:48+00:00

I’ve got a partial control with Ajax.BeginForm containing simple form with one textbox and

  • 0

I’ve got a partial control with Ajax.BeginForm containing simple form with one textbox and validation message. Model is using data annotations to set this field to required.

When above partial control gets loaded in the view directly using Html.RenderPartial then client side validation works fine.

When above partial control gets loaded using Ajax.ActionLink then client validation stops working ( form gets submitted with empty textbox and server side validation works fine ):

Ajax.ActionLink("Create New Job Note", "CreateNew", "JobNotes", 
                new AjaxOptions { UpdateTargetId = "CreateNewJobNote",
                                  HttpMethod="GET" })

I’ve got references to following javascript on my masterpage :

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

Why does client side validation not work when I load the partial control using Ajax.ActionLink?

========== EDIT ==============

As requested, here are relevant code quotes :

1)
I’m loading my partial control containing textbox with this code :

<%:Ajax.ActionLink("Create New Job Note", "CreateNew", "JobNotes", new AjaxOptions { UpdateTargetId = "CreateNewJobNote", HttpMethod="GET" })%>

Controller method :

public ActionResult CreateNew()
        {
            return PartialView("JobNotesCreateNew", new NewJobNoteModel());           
        }

2)
JobNotesCreateNew.ascx :

<% Html.EnableClientValidation();%>
<% using (Ajax.BeginForm("CreateNew", "JobNotes", FormMethod.Post, new AjaxOptions { UpdateTargetId = "JobNotes" }, new { id = "CreateNewJobNoteForm" }))
   { %>
    <%: Html.ValidationSummary(true, "Please correct errors on the form.")%>

    <fieldset>
        <legend>Fields</legend>

        <div class="editor-label">
            <%: Html.LabelFor(model => model.Note)%>
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.Note)%>
            <%: Html.ValidationMessageFor(model => model.Note)%>
        </div>

        <p>
            <input type="submit" value="Create" />
            <%: Ajax.ActionLink("Cancel", "Cancel", "JobNotes", new AjaxOptions { UpdateTargetId = "CreateNewJobNote", HttpMethod = "GET" })%>
        </p>

    </fieldset>

<% } %>

That’s it.
So, to sum up:

  1. a view with ajax action link to my partial control gets loaded.
  2. User clicks on “Create New Job Note”
    ajax action link which loads my
    partial control correctly.
  3. When form from
    JobNotesCreateNew.ascx gets
    submitted using “Create” submit
    button I expect client side
    validation to check if TextBoxFor
    for model.Note is not empty.

But client side validation doesn’t happen and form is posted to the server.
I can see this in firebug.
I can also debug following controller method on server side in VS 2010 :

[HttpPost]
public ActionResult CreateNew(NewJobNoteModel newJobNote)

So my question is : why client side validation is broken?

Thanks.

========== EDIT : 17/11/2010 ==============

Interesting.
I’m using data annotations validation on the model :

public class NewJobNoteModel
    {
        [Required]
        public string Note { get; set; }
    }

Since above validation works fine on client side when using Html.BeginForm() I was assuming it should work in Ajax.BeginForm() scenario as well.
Am I mistaken here? Should I really trigger the validation myself on client side?
I will investigate the article, had a quick look and CompleteFunction looks quite manual over there, I was hoping things to be more automated there.

Thanks!

========== EDIT : 25/11/2010 ==============

OK I found a solution to my problem here :
http://adammcraventech.wordpress.com/2010/06/11/asp-net-mvc2-ajax-executing-dynamically-loaded-javascript/

The AjaxLoadedContentScriptFix.js javascript seems to be working fine for me.

This is the kind of answer I was looking for.
All the other tips like using custom client side validation in AjaxOptions of Ajax.BeginForm – c’mon people 🙂

  • 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-18T05:46:49+00:00Added an answer on May 18, 2026 at 5:46 am

    as mentioned in the original post, here is the solution :
    http://adammcraventech.wordpress.com/2010/06/11/asp-net-mvc2-ajax-executing-dynamically-loaded-javascript/

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
i got an object with contents of html markup in it, for example: string
I've got a string that has curly quotes in it. I'd like to replace
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I want to count how many characters a certain string has in PHP, but
I have a JSP page retrieving data and when single or double quotes are

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.