This is a migrated thread and some comments may be shown as answers.

RequiredFieldValidator not working with RadScriptManager

5 Answers 333 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 14 Jan 2009, 12:32 PM
Hi,
I have one odd problem!
If I add a RadScriptManager on the page all client side validation stop working.
What have I missed?

Testcode:
%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="App.Web.UI.Administration.Secure.test" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title></title
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
    <div> 
         <table class="form"
            <tr> 
                <td class="red">Namn:</td> 
                <td><asp:TextBox ID="textBoxName" runat="server" CssClass="xLarge" ValidationGroup="validationGroupBanner"></asp:TextBox> 
                    <asp:RequiredFieldValidator ID="requiredFieldValidatorName" runat="server"  
                        ControlToValidate="textBoxName" Display="Dynamic" ErrorMessage="obligatorisk"  
                        SetFocusOnError="True" ValidationGroup="validationGroupBanner"></asp:RequiredFieldValidator> 
                </td> 
            </tr> 
        </table> 
    </div> 
    </form> 
</body> 
</html> 

Result:
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head><title
 
</title></head
<body> 
    <form name="form1" method="post" action="test.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="form1"
<div> 
<input type="hidden" name="RadScriptManager1_HiddenField" id="RadScriptManager1_HiddenField" value="" /> 
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /> 
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /> 
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTM2MDkyOTg3MGRkKKxwM9OSYlk1EpTM5Wl6MC4iboc=" /> 
</div> 
 
<script type="text/javascript"
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]> 
</script> 
 
 
<script src="/WebResource.axd?d=PJbs5I8u7UnXghzYecrYew2&amp;t=633527857956801634" type="text/javascript"></script> 
 
 
<script src="/ScriptResource.axd?d=7ZfBM6SkJ6AkD6NPKf2D84lP3jDRYRutI_sNsAMiNpP9Ndvl6rKJDioozY5LQgGdlUnZK2zCZizinGUlzrFvQA2&amp;t=633527857956801634" type="text/javascript"></script> 
<script src="/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_HiddenField&amp;compress=1&amp;_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d1.0.61025.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3a1f0f78f9-0731-4ae9-b308-56936732ccb8%3a52817a7d%3a67c678a8" type="text/javascript"></script> 
<script type="text/javascript"
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]> 
</script> 
 
<div> 
 
    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgLcrOGFAgKPlYESheV+n5Sp2a2I8UvaK2DAJ589lhU=" /> 
</div> 
    <script type="text/javascript"
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('RadScriptManager1', document.getElementById('form1'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls([], [], [], 90);
//]]> 
</script> 
 
    <div> 
         <table class="form"
                   
                        <tr> 
                            <td class="red">Namn:</td> 
                            <td><input name="textBoxName" type="text" id="textBoxName" class="xLarge" /> 
                                <span id="requiredFieldValidatorName" style="color:Red;display:none;">obligatorisk</span> 
                            </td> 
                        </tr> 
              
                    </table> 
    </div> 
     
<script type="text/javascript"
//<![CDATA[
var Page_Validators =  new Array(document.getElementById("requiredFieldValidatorName"));
//]]> 
</script> 
 
<script type="text/javascript"
//<![CDATA[
var requiredFieldValidatorName = document.all ? document.all["requiredFieldValidatorName"] : document.getElementById("requiredFieldValidatorName");
requiredFieldValidatorName.controltovalidate = "textBoxName";
requiredFieldValidatorName.focusOnError = "t";
requiredFieldValidatorName.errormessage = "obligatorisk";
requiredFieldValidatorName.display = "Dynamic";
requiredFieldValidatorName.validationGroup = "validationGroupBanner";
requiredFieldValidatorName.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
requiredFieldValidatorName.initialvalue = "";
//]]> 
</script> 
 
 
<script type="text/javascript"
//<![CDATA[
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
    ValidatorOnLoad();
}
function ValidatorOnSubmit() {
    if (Page_ValidationActive) {
        return ValidatorCommonOnSubmit();
    }
    else {
        return true;
    }
}
        Sys.Application.initialize();
document.getElementById('requiredFieldValidatorName').dispose = function() {
    Array.remove(Page_Validators, document.getElementById('requiredFieldValidatorName'));
}
//]]> 
</script> 
</form> 
</body> 
</html> 
 

Result without scriptmanager, now the validator works:
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head><title
 
</title></head
<body> 
    <form name="form1" method="post" action="test.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="form1"
<div> 
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNjE1MzQwNzgzZGQUXdcWlpAsgxQEdMt/9c9OtbGOYg==" /> 
</div> 
 
 
<script src="/WebResource.axd?d=S67xmpnCynrpCGuTG1uCu5qbsb48xm5XkXRTyH8bt181&amp;t=633527857956801634" type="text/javascript"></script> 
<script type="text/javascript"
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]> 
</script> 
 
<div> 
 
    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKYhNfGBgKPlYESviUaHFwOJ+saekYypJvt3mDGaP4=" /> 
</div> 
    
    <div> 
         <table class="form"
                   
                        <tr> 
                            <td class="red">Namn:</td> 
                            <td><input name="textBoxName" type="text" id="textBoxName" class="xLarge" /> 
                                <span id="requiredFieldValidatorName" style="color:Red;display:none;">obligatorisk</span> 
                            </td> 
                        </tr> 
              
                    </table> 
    </div> 
     
<script type="text/javascript"
//<![CDATA[
var Page_Validators =  new Array(document.getElementById("requiredFieldValidatorName"));
//]]> 
</script> 
 
<script type="text/javascript"
//<![CDATA[
var requiredFieldValidatorName = document.all ? document.all["requiredFieldValidatorName"] : document.getElementById("requiredFieldValidatorName");
requiredFieldValidatorName.controltovalidate = "textBoxName";
requiredFieldValidatorName.focusOnError = "t";
requiredFieldValidatorName.errormessage = "obligatorisk";
requiredFieldValidatorName.display = "Dynamic";
requiredFieldValidatorName.validationGroup = "validationGroupBanner";
requiredFieldValidatorName.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
requiredFieldValidatorName.initialvalue = "";
//]]> 
</script> 
 
 
<script type="text/javascript"
//<![CDATA[
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
    ValidatorOnLoad();
}
function ValidatorOnSubmit() {
    if (Page_ValidationActive) {
        return ValidatorCommonOnSubmit();
    }
    else {
        return true;
    }
}
        //]]> 
</script> 
</form> 
</body> 
</html> 
 

5 Answers, 1 is accepted

Sort by
0
Erjan Gavalji
Telerik team
answered on 14 Jan 2009, 01:53 PM
Hi Mattias,

I just created a page in a simple website, having the content you sent us. I did not have a problem with the validator. Please, find the page attached (along with the web.config file).

Am I missing something?

Kind regards,
Erjan Gavalji
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mattias
Top achievements
Rank 1
answered on 14 Jan 2009, 03:30 PM
Hm, if I upgrade the webproject to ASP.NET 3.5 the validation works so it got to be something with my web.config and version 2.0.
I have to check with my hosting company if it is possible to run version 3.5 on their servers, then it's no problem, otherwise I'll let you know!
0
Accepted
Veselin Vasilev
Telerik team
answered on 14 Jan 2009, 03:38 PM
Hi Mattias,

This should work in ASP.NET 2.0 as well.

Let us know the results.

Sincerely yours,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mattias
Top achievements
Rank 1
answered on 14 Jan 2009, 04:10 PM
Framework 3.5 doesn't seems to be installed! :(

Here is a test project with validation not working, does it work for you?
http://www.svenskwebbhandel.se/validationTest.zip



Can you see anything wrong in web.config, cause it has to something wrong there!

0
Mattias
Top achievements
Rank 1
answered on 14 Jan 2009, 04:22 PM
Hi again!
I found the problem, it was the httphandlers section that was wrong! Now it works! :)
Tags
General Discussions
Asked by
Mattias
Top achievements
Rank 1
Answers by
Erjan Gavalji
Telerik team
Mattias
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or