JScript error with validators inside UpdatePanel

J

J055

Hi

I get a JScript error when I remove a control with a RequiredFieldValidator
during partial page update and then hit a form button with
CausesValidation=true. The button is outside the UpdatePanel which contains
the validators although it still seems to happen if I put the button inside
another UpdatePanel.

The client call stack is:
ValidatorGetValue JScript
RequiredFieldValidatorEvaluateIsValid JScript
ValidatorValidate JScript
Page_ClientValidate JScript
WebForm_DoPostBackWithOptions JScript
Sys$WebForms$PageRequestManager$_doPostBackWithOptions JScript
JScript anonymous function JScript
JScript - aspnetForm onclick function JScript

This function fails because the control field is null.
function ValidatorGetValue(id) {
var control;
control = document.getElementById(id);
if (typeof(control.value) == "string") {
return control.value;
}
return ValidatorGetValueRecursive(control);
}

What should I do to avoid this happening?

Thanks
Andrew
 
V

Vince Xu [MSFT]

Hello Andrew,

Did you use updated versions of the validators that are compatible with
UpdatePanel? Please check the following link:
http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

If it's still not working, please post your code or source code files to me
if you don't mind. (My Email is (e-mail address removed))


Sincerely,

Vince Xu

Microsoft Online Support


==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================



--------------------
| From: "J055" <[email protected]>
| Subject: JScript error with validators inside UpdatePanel
| Date: Tue, 19 May 2009 17:29:02 +0100
| Lines: 34
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| X-MS-CommunityGroup-MessageCategory:
{E4FCE0A9-75B4-4168-BFF9-16C22D8747EC}
| X-MS-CommunityGroup-PostID: {005DB728-451D-4E58-B3F9-53964865D978}
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 88-97-199-158.dsl.zen.co.uk 88.97.199.158
| Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP04.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:87827
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi
|
| I get a JScript error when I remove a control with a
RequiredFieldValidator
| during partial page update and then hit a form button with
| CausesValidation=true. The button is outside the UpdatePanel which
contains
| the validators although it still seems to happen if I put the button
inside
| another UpdatePanel.
|
| The client call stack is:
|
| > ValidatorGetValue JScript
| RequiredFieldValidatorEvaluateIsValid JScript
| ValidatorValidate JScript
| Page_ClientValidate JScript
| WebForm_DoPostBackWithOptions JScript
| Sys$WebForms$PageRequestManager$_doPostBackWithOptions JScript
| JScript anonymous function JScript
| JScript - aspnetForm onclick function JScript
|
| This function fails because the control field is null.
| function ValidatorGetValue(id) {
| var control;
| control = document.getElementById(id);
| if (typeof(control.value) == "string") {
| return control.value;
| }
| return ValidatorGetValueRecursive(control);
| }
|
| What should I do to avoid this happening?
|
| Thanks
| Andrew
|
|
 
V

Vince Xu [MSFT]

Hello Andrew,

Did you use updated versions of the validators that are compatible with
UpdatePanel? Please check the following link:
http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

If it's still not working, please post your code or source code files to me
if you don't mind. (My Email is (e-mail address removed))


Sincerely,

Vince Xu

Microsoft Online Support


==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================



--------------------
| From: "J055" <[email protected]>
| Subject: JScript error with validators inside UpdatePanel
| Date: Tue, 19 May 2009 17:29:02 +0100
| Lines: 34
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| X-MS-CommunityGroup-MessageCategory:
{E4FCE0A9-75B4-4168-BFF9-16C22D8747EC}
| X-MS-CommunityGroup-PostID: {005DB728-451D-4E58-B3F9-53964865D978}
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 88-97-199-158.dsl.zen.co.uk 88.97.199.158
| Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP04.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:87827
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi
|
| I get a JScript error when I remove a control with a
RequiredFieldValidator
| during partial page update and then hit a form button with
| CausesValidation=true. The button is outside the UpdatePanel which
contains
| the validators although it still seems to happen if I put the button
inside
| another UpdatePanel.
|
| The client call stack is:
|
| > ValidatorGetValue JScript
| RequiredFieldValidatorEvaluateIsValid JScript
| ValidatorValidate JScript
| Page_ClientValidate JScript
| WebForm_DoPostBackWithOptions JScript
| Sys$WebForms$PageRequestManager$_doPostBackWithOptions JScript
| JScript anonymous function JScript
| JScript - aspnetForm onclick function JScript
|
| This function fails because the control field is null.
| function ValidatorGetValue(id) {
| var control;
| control = document.getElementById(id);
| if (typeof(control.value) == "string") {
| return control.value;
| }
| return ValidatorGetValueRecursive(control);
| }
|
| What should I do to avoid this happening?
|
| Thanks
| Andrew
|
|
 
B

bruce barker

if the validator is outside the update panel, you will need to render
javascript to disable the validator (as it will not know the control was
removed). when you remove the control you can check if its an async
postback and render a startup script via scriptmanager to do the disable.

-- bruce (sqlwork.com)
 
B

bruce barker

if the validator is outside the update panel, you will need to render
javascript to disable the validator (as it will not know the control was
removed). when you remove the control you can check if its an async
postback and render a startup script via scriptmanager to do the disable.

-- bruce (sqlwork.com)
 
J

J055

Hi

Do I need the to use these validators if I'm working with a project using
the latest FrameWork 3.5?

Thanks
Andrew
 
J

J055

Hi

Do I need the to use these validators if I'm working with a project using
the latest FrameWork 3.5?

Thanks
Andrew
 
V

Vince Xu [MSFT]

Hello Andrew,

If you used FrameWork 3.5, it should be working in UpdatePanel.
In this scenario, it throws the "null" error since ValidatorGetValue can't
find the Target Control. I guess the Target Control was removed but
Validator control was still working. Thus it can't find the Target Control
which has been removed, so it throws the error.

If this is what you encountered, please disable the Validator while you
remove the Target Control as Bruce said.

function pageLoad() {
ValidatorEnable($get('RequiredFieldValidator1'), false); // Use
JavaScript to disable Validator.
}

Moreover, I'm not clear about how you remoeved them. Did you use the
following code to remove these both controls?

UpdatePanel1.ContentTemplateContainer.Controls.Remove(TextBox1);

UpdatePanel1.ContentTemplateContainer.Controls.Remove(RequiredFieldValidator
1);


If the above all can't help you out, please send me your demo/smample so
that I can reproduct the problem in my site?



Sincerely,

Vince Xu

Microsoft Online Support
 
V

Vince Xu [MSFT]

Hello Andrew,

If you used FrameWork 3.5, it should be working in UpdatePanel.
In this scenario, it throws the "null" error since ValidatorGetValue can't
find the Target Control. I guess the Target Control was removed but
Validator control was still working. Thus it can't find the Target Control
which has been removed, so it throws the error.

If this is what you encountered, please disable the Validator while you
remove the Target Control as Bruce said.

function pageLoad() {
ValidatorEnable($get('RequiredFieldValidator1'), false); // Use
JavaScript to disable Validator.
}

Moreover, I'm not clear about how you remoeved them. Did you use the
following code to remove these both controls?

UpdatePanel1.ContentTemplateContainer.Controls.Remove(TextBox1);

UpdatePanel1.ContentTemplateContainer.Controls.Remove(RequiredFieldValidator
1);


If the above all can't help you out, please send me your demo/smample so
that I can reproduct the problem in my site?



Sincerely,

Vince Xu

Microsoft Online Support
 
J

J055

Hi there

Thanks for all your help. I've decided to disable client-side validation for
the moment. I'll have another look at this in the near future.

Cheers
Andrew
 
J

J055

Hi there

Thanks for all your help. I've decided to disable client-side validation for
the moment. I'll have another look at this in the near future.

Cheers
Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top