Custom Validator doesn't work  
Author Message
Juwae





PostPosted: Mon Mar 27 05:26:52 CST 2006 Top

ASP.Net >> Custom Validator doesn't work

Well,

I've tried to create a stupid custom validator to validate a checked checkbox.
Really simple, really stupid, but it's just for trying to do something better
than standard validator, that works great but has some limits.

Ok, this is what i've done (apart from the basic implementation that should
be done):

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);

if (RenderUplevel)
{
string script = "\r\n<script language=\"javascript\">\r\n" +
..............

to implement the script


and

protected override void AddAttributesToRender(HtmlTextWriter writer)
{
//writer.AddAttribute("controltovalidate", this.GetControlRenderID(ControlToValidate));
base.AddAttributesToRender(writer);

if (this.RenderUplevel)
{
String clientID = this.ClientID;

Page.ClientScript.RegisterExpandoAttribute(clientID, "evaluationfunction",
"IsCheckBoxRequired");

..............

to add the javascript elements to the javascript code rendered by the framework.

I've tried both Firefox and IE, on XP PRO nor on a Windows 2003. In both
case IE seems to works, but in firefox doesn't.
At least the client-script doesn't fire.

Infact checking in the source code the

ctl00_MainContent_Control.evaluationfunction = "JavascriptFunctionName";

isn't there despite the RegisterExpandoAttribute set it correctly. Using
the writer.AddAttribute() in the AddAttributeToRender doesn't work either.

I really don't know.

I'm exausted and upset. I wasted half day to understand the reason ...

Any help?

Thanks Andrea

Web Programming383  
 
 
eguworks





PostPosted: Mon Mar 27 05:26:52 CST 2006 Top

ASP.Net >> Custom Validator doesn't work Hello Andrea,

Have you considered Firefox being the problem?
Perhaps checking the firefox forum or actually mailing mozilla about it
will clarify.
I myself have noticed all kinds of small differences when comparing IE
and firefox.

another solution might be using a validationControl from asp.net 2.0
or you can always do something like if checkbox1.checked = true etc etc

Egu