Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > can't get evaluationfunction attribute set correctly on CustomValidator

Reply
Thread Tools

can't get evaluationfunction attribute set correctly on CustomValidator

 
 
TS
Guest
Posts: n/a
 
      08-03-2007
i want to specify evalutionfunction for my custom validator control. i have
tried many ways to get this to work, but in the end, the evaluationfunction
attribute always gets rendered as the default
"CustomValidatorEvaluateFunction":

<span
id="ctl00_ctl00_ContentMainPlaceHolder_Application ContentMainPlaceHolder_cbC
lientSigned" evaluationfunction="CustomValidatorEvaluateFunctio n"
requiredfield="false" validatewhenempty="false" label="" validationGroup1
mustBeChecked="true" style="color:Red;display:none;"></span>

protected override void AddAttributesToRender(HtmlTextWriter writer){
base.AddAttributesToRender(writer); string x;
//this.ClientValidationFunction = "CheckBoxValidatorEvaluateIsValid";
//writer.AddAttribute("evaluationfunction",
"CheckBoxValidatorEvaluateIsValid", false);
Attributes.Add("evaluationfunction", "CheckBoxValidatorEvaluateIsValid");
writer.AddAttribute("mustBeChecked", MustBeChecked ? "true" : "false",
false);
}

how do i do this correctly? I have tried to also not override
AddAttributesToRender and instead in prerender just add these 2 attributes.
No matter what i do, evaluationfunction gets overwritten somewhere

what can i do?


 
Reply With Quote
 
 
 
 
TS
Guest
Posts: n/a
 
      08-03-2007
i found out that this is in the base class to my class (which is inherited
from customvalidator)
protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter
writer)

{

/// TODO: Get rid of the Custom EvaluationFunction

Attributes.Remove("evaluationfunction");

Attributes["evaluationfunction"] = "CustomValidatorEvaluateFunction";

base.AddAttributesToRender(writer);

writer.AddAttribute("requiredfield", RequiredField.ToString().ToLower());

writer.AddAttribute("validatewhenempty",
ValidateEmptyText.ToString().ToLower());

writer.AddAttribute("label", Label);

writer.AddAttribute("validationGroup1", ValidationGroup1);

}

i tried the same remove() function as above in my overriden method but no
luck


"TS" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> i want to specify evalutionfunction for my custom validator control. i

have
> tried many ways to get this to work, but in the end, the

evaluationfunction
> attribute always gets rendered as the default
> "CustomValidatorEvaluateFunction":
>
> <span
>

id="ctl00_ctl00_ContentMainPlaceHolder_Application ContentMainPlaceHolder_cbC
> lientSigned" evaluationfunction="CustomValidatorEvaluateFunctio n"
> requiredfield="false" validatewhenempty="false" label="" validationGroup1
> mustBeChecked="true" style="color:Red;display:none;"></span>
>
> protected override void AddAttributesToRender(HtmlTextWriter writer){
> base.AddAttributesToRender(writer); string x;
> //this.ClientValidationFunction = "CheckBoxValidatorEvaluateIsValid";
> //writer.AddAttribute("evaluationfunction",
> "CheckBoxValidatorEvaluateIsValid", false);
> Attributes.Add("evaluationfunction", "CheckBoxValidatorEvaluateIsValid");
> writer.AddAttribute("mustBeChecked", MustBeChecked ? "true" : "false",
> false);
> }
>
> how do i do this correctly? I have tried to also not override
> AddAttributesToRender and instead in prerender just add these 2

attributes.
> No matter what i do, evaluationfunction gets overwritten somewhere
>
> what can i do?
>
>



 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      08-05-2007
They aren't written from Attributes collection but directly as expando
attribute on the derived, concrete validator implementation

protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender(writer);
if (base.RenderUplevel)
{
string controlId = this.ClientID;
HtmlTextWriter writer2 = base.EnableLegacyRendering ? writer : null;
base.AddExpandoAttribute(writer2, controlId, "evaluationfunction",
"CustomValidatorEvaluateIsValid", false);
if (this.ClientValidationFunction.Length > 0)
{
//client-side registration
}
}
}

AddExpandoAttribute is implemented as follows

internal static void AddExpandoAttribute(Control control, HtmlTextWriter
writer, string controlId, string attributeName, string attributeValue, bool
encode)
{
if (writer != null)
{
writer.AddAttribute(attributeName, attributeValue, encode);
}
else
{
control.Page.ClientScript.RegisterExpandoAttribute (control,
controlId, attributeName, attributeValue, encode);
}
}


so basically you could try registering the attribute with
control.Page.ClientScript.RegisterExpandoAttribute yourself.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net





"TS" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>i found out that this is in the base class to my class (which is inherited
> from customvalidator)
> protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter
> writer)
>
> {
>
> /// TODO: Get rid of the Custom EvaluationFunction
>
> Attributes.Remove("evaluationfunction");
>
> Attributes["evaluationfunction"] = "CustomValidatorEvaluateFunction";
>
> base.AddAttributesToRender(writer);
>
> writer.AddAttribute("requiredfield", RequiredField.ToString().ToLower());
>
> writer.AddAttribute("validatewhenempty",
> ValidateEmptyText.ToString().ToLower());
>
> writer.AddAttribute("label", Label);
>
> writer.AddAttribute("validationGroup1", ValidationGroup1);
>
> }
>
> i tried the same remove() function as above in my overriden method but no
> luck
>
>
> "TS" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> i want to specify evalutionfunction for my custom validator control. i

> have
>> tried many ways to get this to work, but in the end, the

> evaluationfunction
>> attribute always gets rendered as the default
>> "CustomValidatorEvaluateFunction":
>>
>> <span
>>

> id="ctl00_ctl00_ContentMainPlaceHolder_Application ContentMainPlaceHolder_cbC
>> lientSigned" evaluationfunction="CustomValidatorEvaluateFunctio n"
>> requiredfield="false" validatewhenempty="false" label="" validationGroup1
>> mustBeChecked="true" style="color:Red;display:none;"></span>
>>
>> protected override void AddAttributesToRender(HtmlTextWriter writer){
>> base.AddAttributesToRender(writer); string x;
>> //this.ClientValidationFunction = "CheckBoxValidatorEvaluateIsValid";
>> //writer.AddAttribute("evaluationfunction",
>> "CheckBoxValidatorEvaluateIsValid", false);
>> Attributes.Add("evaluationfunction", "CheckBoxValidatorEvaluateIsValid");
>> writer.AddAttribute("mustBeChecked", MustBeChecked ? "true" : "false",
>> false);
>> }
>>
>> how do i do this correctly? I have tried to also not override
>> AddAttributesToRender and instead in prerender just add these 2

> attributes.
>> No matter what i do, evaluationfunction gets overwritten somewhere
>>
>> what can i do?
>>
>>

>
>



 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      08-09-2007
Thanks Teemu for your informative input.

Hi TS,

Please feel free to let us know if there's anything unclear. Thanks.


Regards,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
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
How to generate readonly attribute correctly? Hamed ASP .Net 3 07-09-2006 01:23 PM
How to generate readonly attribute correctly? Hamed ASP .Net Datagrid Control 3 07-09-2006 01:23 PM
ValidationControl evaluationfunction ASP.NET 2.0 jeremy.brewster@akqa.com ASP .Net Web Controls 7 07-04-2006 12:11 PM
get and set Attribute for EJB Context (Storing objects) JehanNYNJ@aol.com Java 2 12-08-2004 10:26 PM
servlet/jsp question: tomcat 4 and login (about session, forward and get/set attribute) Mladen Adamovic Java 3 11-16-2003 04:54 PM



Advertisments