473,508 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem registering startup script in a Ajax Validator

I have a RangeValidator which uses AJAX to call server-side validation
function from the client. The code works fine, but I have one problem.

following is my range validator class:

public class RangeValidator: BaseValidator,ICallbackEventHandler
{
public event ServerValidateEventHandler ServerValidate;
String _controlToValidateValue;

protected override void OnPreRender(EventArgs e)
{
String eventRef =
Page.ClientScript.GetCallbackEventReference(this, "", "", "");

// Register include file
String includeScript = Page.ResolveClientUrl("~/
ClientScripts/AjaxValidator.js");

Page.ClientScript.RegisterClientScriptInclude("MyA jaxValidator",
includeScript);

// Register startup script
String startupScript =
String.Format("document.getElementById('{0}').eval uationfunction =
'AjaxValidatorEvaluateIsValid';", this.ClientID);
Page.ClientScript.RegisterStartupScript(this.GetTy pe(),
this.ClientID, startupScript);

base.OnPreRender(e);
}
.....
}

This is how I use it in the aspx file

<cc1:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="Test1"
Display="Dynamic" OnServerValidate="test1_servervalidate"></
cc1:RangeValidator>
<cc1:RangeValidator ID="RangeValidator2" runat="server"
ControlToValidate="Test2"
Display="Dynamic" OnServerValidate="test2_servervalidate"></
cc1:RangeValidator>

So the onPreRender is called twice when this page loads. The code
compiles and the validation works fine, but only for the first "Test1"
control only. And it doesnt fire the validation events for the second
one.

Here is how it is rendered:

<script type="text/javascript">
<!--
WebForm_InitCallback();document.getElementById('Ra ngeValidator1').evaluationfunction
= 'AjaxValidatorEvaluateIsValid';// -->
</script>

<script type="text/javascript">
<!--
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
ValidatorOnLoad();
}

function ValidatorOnSubmit() {
if (Page_ValidationActive) {
return ValidatorCommonOnSubmit();
}
else {
return true;
}
}
// -->
</script>

<script type="text/javascript">
<!--
document.getElementById('RangeValidator2').evaluat ionfunction =
'AjaxValidatorEvaluateIsValid';// -->
</script>

Any idea on why this is not working for the second validator? Thanks
in advance.

Jan 31 '07 #1
0 1185

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

Similar topics

9
7764
by: Christian Hubinger | last post by:
Hi! I've implemented some DropDown list in ASP.NET that use Ajax to fetch the data from the server. The javascript is written to call cascading to the bottom most dropdown in order to update...
1
3505
by: Todd | last post by:
I am using RegisterStartupScript within an asp.net code behind. Sometime, after the page is Posted Back, I need to remove the Registered startup script. Is there any way to remove that from the...
2
1216
by: bill yeager | last post by:
I'm registering a startup script in my "page load" event. Everything works fine when I run it locally, but when it's deployed to the webserver, it doesn't execute the javascript which is inside a...
5
1292
by: bspittles | last post by:
Can anyone tell me why the following script doesn't work in Firefox 1.5 (not sure about other versions) when it works fine in IE6 and Netscapes 7.1? Almost as importantly ;) can ayone tell me how...
102
6684
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem...
0
5432
by: Jay Douglas | last post by:
Hello all, I'm in need of a custom validator that: 1). Runs server side code using ajax through a client validate function 2). Client validate function does not set args.IsValid until the...
3
2577
omerbutt
by: omerbutt | last post by:
hi there i have downloaded a prototype tooltip from http://www.nickstakenburg.com/projects/prototip/ the logic it uses is to call the script after creating the <div> for example i am using the...
1
1153
by: Stratum | last post by:
I use ASP.Net Validator controls on some Web pages, specifically, the Required Field Validator which works on the client side before a postback. The page has worked fine for some time. After I...
4
3144
by: Dave Burns | last post by:
I am self hosting a Web Service in a Windows service. I am trying to start the service using the NT AUTHORITY\NetworkService account. I get a NullReferenceException on ServiceHost.Open() in the...
0
7225
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
7326
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
7385
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
7498
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...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3195
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.