473,396 Members | 1,933 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.

.Net validators broken by client-side script (cloneNode does not copy onchange handler)

I am doing some some HTML manipulation in client-side script (IE5.x and IE6.x browsers only).
Something like..

var tmpHTML = oTable.outerHTML
// do something to the HTML her
oTable.outerHTML = tmpHTML

Before the changes, client-side .Net field validators (RegularExpressionValidator, RangeValidator, etc.) work fine... after the changes, the modified HTML works correctly but the validators stop functioning. Seems that the onchange handler of input elements is set by client-side script in WebUIValidation.js

I tried calling ValidatorOnLoad(); hoping to reset all the page's validators, but that didn't work. I think it's because that function is dependent on Page_Validators which is an array of objects instead of object ID's

The onchange handlers I'm trying to preserve do not show up in innerHTML or outerHTML... so they can't be preserved when making dynamic changes to HTML
I was hoping that calling cloneNode on the table I was working on would capture the event handlers but it also skips those (see sample code that demonstrates this below)

So... to the point..
Onchange event handlers generated by .Net validators are applied to page elements in client-side script
Is there a way to preserve the handlers when making modifications (via client side script) to the HTML of the elements the validators are connected to (via the controltovalidate attribute)

Sidenote
I have a hunch that cloneNode not copying these handlers is why IE's Smart Navigation feature causes problems with more advanced pages... but that's just a guess

Thanks
-Mat
______________________________________________
<html><body><form id=form1><input id='moo' type=text onchange="alert('Onchange was not dynamically replaced')" value='MooCow'></form><script
var tmpObj = document.all['moo']
tmpObj.onchange = new Function ("alert('Changed to ' + document.all['moo'].value); ")
alert("Original Object \r\nValue: " + tmpObj.value + "\r\nOnchange: \r\n" + tmpObj.onchange)

var clonedObj = tmpObj.cloneNode(true)
alert("Cloned Object \r\nValue: " + clonedObj.value + "\r\nOnchange: \r\n" + clonedObj.onchange)
</script></body></html
__________________________________________________ _____________

Nov 18 '05 #1
2 1376
"MonkeyBoy" <an*******@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
I am doing some some HTML manipulation in client-side script (IE5.x and IE6.x browsers only). Something like...

var tmpHTML = oTable.outerHTML;
// do something to the HTML here
oTable.outerHTML = tmpHTML;

Before the changes, client-side .Net field validators

(RegularExpressionValidator, RangeValidator, etc.) work fine... after the
changes, the modified HTML works correctly but the validators stop
functioning. Seems that the onchange handler of input elements is set by
client-side script in WebUIValidation.js.

Maybe the following article will help:
ASP.NET Validation in Depth
(http://msdn.microsoft.com/library/de...-us/dnaspp/htm
l/aspplusvalid.asp).
--
John Saunders
johnwsaundersiii at hotmail

Nov 18 '05 #2

That's a very detailed article
Thank you

The client-side validators work by adding functions to the onchange property of the objects they validate
I guess because these are 'dynamically' added, they do not show up in the outerHTML of the objects

I ended up writing a client-side routine that recreates the validators and called it whenever the HTML for objects (text inputs) being validated was changed
Nov 18 '05 #3

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

Similar topics

2
by: Frank de Bot | last post by:
Hi, occasionaly I find in my apache logs that fastcgi had a broken pipe error with php running as fastcgi. the logs are like this: -- > (32)Broken pipe: > FastCGI: comm with server...
3
by: Gerson Kurz | last post by:
I have problems getting "COM makepy" working in ActivePython 2.3.2. This is what happens when I start "COM makepy" from the Pythonwin Menu: PythonWin 2.3.2 (#49, Nov 6 2003, 10:18:20) on...
2
by: JD | last post by:
I'm trying to add a custom utility.mde reference to an application from code using the standard Application.References.AddFromFile code. IT has worked really well with A2K for a couple of years but...
7
by: Bill Richardson | last post by:
We have a technique for our order process whereby we simply turn panels on and off to capture data for the various stages, rather than the normal method of moving between pages. In 1.0, the...
6
by: Mark | last post by:
We have Validators embedded in an asp table server control. The table server control is necessary and cannot be replaced. We want to apply CSS formatting to the validators, but the validators...
4
by: jobz | last post by:
I have a multi-page form that contains various validators. When the user clicks the submit button, I want validators to fire in all panels, not just the one currently visible. Can anyone help? ...
3
by: John Blair | last post by:
Hi, I have validators outside of a datagrid (for adding a new grid row) - however when i click "edit" column and then the "update" column of a grid row that has been edited - my other...
1
by: Robin | last post by:
In an ASP.Net Web page that has multiple Required field validators and a command button. The when clicking the button the click event does not occur until all validator conditions are meet. Is...
1
by: COHENMARVIN | last post by:
I'm working on a project which has a screen with edit fields, and two buttons on the bottom. One button says SAVE and the other button says DELETE. I want to use validators on the fields, but the...
2
by: Alec MacLean | last post by:
Hi, I have a page using AJAX. The page has three modal popups that work fine when I don't have field validators in place. As soon as I put a validator in place, the popup "form" the validator...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.