473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASP.NET 2.0 clientvalidationfunction Firing When it Shouldn't

I've got an ASP.NET form with a textbox and a customvalidator. The
form inherits from a base wizard class with back, next and cancel
buttons. The CausesValidation property of the Cancel button gets set
to false, yet the javascript clientvalidationfunction is firing when
the cancel button is hit. Running through the debugger, the
CausesValidation property is set to false on the Page_Load of the
derived form. Why is the clientside javascript firing even though
causesvalidation is false? How do I stop this?

Apr 3 '06 #1
10 2571
sam
Hello,

Please do a view source and paste that buttons onclick code here so we
can be sure its doing client side validation. You will see a
Page_ClientValidate() call on the onclick if it is. Also overload
OnPreRender() and make sure CausesValidation is not changed. I'd like
to see that html mentioned above if you care to post it.

-sam

Apr 3 '06 #2
Here is the relevant code form the 'view source':
<script language="javascript">
<!--
function OnPasswordValidate(source, arguments) {
arguments.IsValid = pwd1.value == pwd2.value;
}
// -->

<td colspan="2"><input name="_ctl_AuthPage:_ctl22:tbxPassword"
type="password" id="_ctl_AuthPage__ctl22_tbxPassword" tabindex="5"
class="TextBox" style="width:350px;" /></td>
<td align="right"><span id="_ctl_AuthPage__ctl22_pwdCustomValidator"
title="Password must contain at least 6 characters"
evaluationfunction="CustomValidatorEvaluateIsValid "
clientvalidationfunction="OnPasswordValidate"
style="color:Red;visibility:hidden;"><img align='absmiddle'
src='/proCube/images/err.gif'/></span></td>

<a id="_ctl_AuthPage__ctl22__btnCancel" style="MARGIN-LEFT: 10px"
class="Button" tabindex="204" direct="true"
href="javascript:__doPostBack('_ctl_AuthPage$_ctl2 2$_btnCancel','')">Cancel</a></td>

Apr 3 '06 #3
sam
----
<a id="_ctl_AuthPage__ctl22__btnCancel" style="MARGIN-LEFT: 10px"
class="Button" tabindex="204" direct="true"
href="javascript:__doPostBack('_ctl_AuthPage$_ctl2 2$_btnCancel','')">Cancel*</a></
----
Client side validation is not happening here. It is happening on the
server. Look closely and you should notice the form posting back when
you press 'Cancel'.

Try setting CausesPostBack to false and see if that fixes it.

-
Sam

Apr 3 '06 #4
Client side validation is happening - when I hit the cancel button, it
never makes it back to the server - the OnPasswordValidate method is
executed and it short circuits the call back to the server. We do want
the cancel button to post back to the server, we just don't want the
client side validation function to execute on cancel.

Apr 4 '06 #5
Here's more info. Setting it to not postback to the server doesn't
help - also the error message displayed is only exists in the cleint
side code, so I know it is hitting the client side validation. I put a
break point in the clientside validation method and it got hit as well.
The stack is:
__doPostBack
common_newPostback
Page_ClientValidate
ValidatorValidate
CustomValidatorEvaluateIsValid
OnPasswordValidate

How do I stop the client validation from happening here?

Apr 4 '06 #6
mw*****@gmail.com wrote:
Here's more info. Setting it to not postback to the server doesn't
help - also the error message displayed is only exists in the cleint
side code, so I know it is hitting the client side validation. I put a
break point in the clientside validation method and it got hit as well.
The stack is:
__doPostBack
common_newPostback
Page_ClientValidate
ValidatorValidate
CustomValidatorEvaluateIsValid
OnPasswordValidate

How do I stop the client validation from happening here?

You can set the CausesValidation property for the button to false.
Apr 4 '06 #7
hm... quoting from my initial post:
"The CausesValidation property of the Cancel button gets set
to false,"

Apr 4 '06 #8
sam
This 'common_newPostback' - did you write that javascript? That's
where the problem is. ASP.Net 1.1 does not have any such function in
__doPostback. In regular asp.net, __doPostback basically just does a
form submit.

I'm afraid its your own client side javascript code that isn't doing
what you want. You'll have to see who rewrote __doPostBack and how to
fix it.

-Sam

Apr 4 '06 #9
sam
BTW, there's a chance that __doPostBack has been rewritten in asp.net
2.0 to do this common_newPostback, altho i googled it and didn't get
any hits. If that's the case, could you tell me? It would be a new
thing to learn about 2.0.

-Sam

Apr 4 '06 #10
sam
It just occured to me to make sure you have CausesPostback of that
button set to false.

-sam

Apr 6 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marie Mercier | last post by:
Hi, I would like to know when a listview is clicked in the background, instead of on an existing column. I noticed that the 'Click' event does not fire if there are no items in the listview....
2
by: Devin Fensterheim | last post by:
Does anyone know of an issue with a control's viewstate not persisting when dynamically adding custom controls to a web form using AddAt? If a control is added to an HTML form directly using the...
5
by: Dan | last post by:
Hi, I'm going crazy here, please help. I have a parent page that has a user control on it that bubbles up data from a dropdown menu. The drop down menus are populated by a set of radio buttons,...
2
by: ~~~ .NET Ed ~~~ | last post by:
I have a problem (don't we all?). I have a web form with multiple modules, some of these modules have an ASP.NET (server run) button. OK, now I have UserControlX which has one such button (say...
8
by: walesboy | last post by:
greetings - I have a btnSubmit button with a Handles btnSubmit.click which works great if all the user does is click that button. But, if the user ALSO changes a text box on the page (which...
0
by: mwieder | last post by:
I've got an ASP.NET form with a textbox and a customvalidator. The form inherits from a base wizard class with back, next and cancel buttons. The CausesValidation property of the Cancel button...
10
by: John Kotuby | last post by:
Hello all... I am working on an ASP.NET 2.0 application with VS2005 and VB. I have chosen to use popup windows in some cases because it makes the user experience better (according to all the users...
1
by: mark4asp | last post by:
How can I stop a post back from firing when there is no need for it to? I have a GridView pager template (shown below): There are 3 commands: ddlPager_SelectedIndexChanged - move the page to...
1
by: Claudiu | last post by:
Hi, I have the following code and no matter what I do onclick event for button is not firing. I tried deleting the button, the pages. Redid the code. Moved the web project to a different...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.