ASP.Net Validation not working when calling page via ajax

Posted on 2009-04-17
Last Modified: 2013-11-07
I have a page "MyPage.aspx" that calls "MyForm.aspx" with prototype

new Ajax.Updater('display', '/myform.aspx'  etc....

However, when the page renders there are no validation scripts on the page.

ie, i don't see scripts like below when i call the page via ajax. If just call myForm.aspx i see the below scripts

<script type="text/javascript">


    var FlagForm1_RequiredFieldValidator1 = document.all ? document.all["FlagForm1_RequiredFieldValidator1"] : document.getElementById("FlagForm1_RequiredFieldValidator1");

    FlagForm1_RequiredFieldValidator1.controltovalidate = "FlagForm1_TextBoxName";

    FlagForm1_RequiredFieldValidator1.errormessage = "RequiredFieldValidator";

    FlagForm1_RequiredFieldValidator1.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";

    FlagForm1_RequiredFieldValidator1.initialvalue = "";

    var FlagForm1_RequiredFieldValidator2 = document.all ? document.all["FlagForm1_RequiredFieldValidator2"] : document.getElementById("FlagForm1_RequiredFieldValidator2");

    FlagForm1_RequiredFieldValidator2.controltovalidate = "FlagForm1_TextBoxEmail";

    FlagForm1_RequiredFieldValidator2.errormessage = "RequiredFieldValidator";

    FlagForm1_RequiredFieldValidator2.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";

    FlagForm1_RequiredFieldValidator2.initialvalue = "";

    var FlagForm1_RequiredFieldValidator3 = document.all ? document.all["FlagForm1_RequiredFieldValidator3"] : document.getElementById("FlagForm1_RequiredFieldValidator3");

    FlagForm1_RequiredFieldValidator3.controltovalidate = "FlagForm1_TextBoxComment";

    FlagForm1_RequiredFieldValidator3.errormessage = "RequiredFieldValidator";

    FlagForm1_RequiredFieldValidator3.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";

    FlagForm1_RequiredFieldValidator3.initialvalue = "";



Open in new window

Question by:frosty1
    1 Comment
    LVL 5

    Accepted Solution

    Try putting the validation  under updatepanel and try

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now