Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Custom Validator doesn't work

Reply
Thread Tools

Custom Validator doesn't work

 
 
Andrea
Guest
Posts: n/a
 
      03-27-2006
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(clientI D, "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




 
Reply With Quote
 
 
 
 
eguworks@gmail.com
Guest
Posts: n/a
 
      03-27-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts Validator - creditCard validator smrimell@gmail.com Java 4 02-13-2007 08:32 PM
How to get custom control to work with custom validator Scott Yenor ASP .Net Web Controls 0 01-27-2004 12:37 AM
Custom Validator Issue Arvind P Rangan ASP .Net 1 11-12-2003 03:28 PM
custom validator Mike P ASP .Net 2 11-05-2003 03:25 PM
Custom Validator Serdar Kalaycę ASP .Net 1 07-08-2003 01:36 PM



Advertisments