DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 3 Aug 2007 15:14:54 -0500,    posted on: microsoft.public.dotnet.framework.aspnet.buildingcontrols        back       

Thread Index
  1    TS am
          2    TS am
          3    Teemu Keiski
          4    (Walter Wang [MSFT])


can't get evaluationfunction attribute set correctly on CustomValidator   
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_ApplicationContentMainPlaceHolder_cbC
lientSigned" evaluationfunction="CustomValidatorEvaluateFunction"
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?
Date:Fri, 3 Aug 2007 15:14:54 -0500   Author:  

Re: can't get evaluationfunction attribute set correctly on CustomValidator   
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" <manofsteele1@nospam.nospam> wrote in message
news:OHJf1rg1HHA.1164@TK2MSFTNGP02.phx.gbl...

> 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_ApplicationContentMainPlaceHolder_cbC

> lientSigned" evaluationfunction="CustomValidatorEvaluateFunction"
> 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?
>
>
Date:Fri, 3 Aug 2007 15:38:28 -0500   Author:  

Re: can't get evaluationfunction attribute set correctly on CustomValidator   
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" <manofsteele1@nospam.nospam> wrote in message 
news:ee0oA5g1HHA.5532@TK2MSFTNGP02.phx.gbl...

>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" <manofsteele1@nospam.nospam> wrote in message
> news:OHJf1rg1HHA.1164@TK2MSFTNGP02.phx.gbl...
>> 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_ApplicationContentMainPlaceHolder_cbC
>> lientSigned" evaluationfunction="CustomValidatorEvaluateFunction"
>> 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?
>>
>>
>
> 
Date:Sun, 5 Aug 2007 10:46:15 +0300   Author:  

Re: can't get evaluationfunction attribute set correctly on CustomValidator   
Thanks Teemu for your informative input.

Hi TS,

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


Regards,
Walter Wang (wawang@online.microsoft.com, 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.
Date:Thu, 09 Aug 2007 02:46:09 GMT   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us