Feb 7, 2010

11:45 PM - ,, 1 comment

Disable CallOut Validator

AjaxToolkit ValidatorCalloutExtender control provides you a new (of course, a nice) way to display your validate message. Although still have some inconveniences but it's worth to try :))

One of inconveniences is when you disable your target validator control by JavaScript (4 example, call ValidatorEnable(targetValidateControl, false)) the callout validator popup still shows every time you focus to the control.

Here's the solution to fix this issuer :

1.Set CSS class for ValidatorCalloutExtender:

HTML Code:

<style id = "style1" type="text/css">
.CustomValidator
{
position: relative;
margin-left: -80px;
margin-top: 8px;
display: inherit;
}
</style>
<ajax:ValidatorCalloutExtender ID="ProductIncrementVE" runat="server"
TargetControlID="ProductIncrementValidator"
HighlightCssClass="validator"
WarningIconImageUrl="~/img/blank.gif"
CssClass="CustomValidator">


</ajax:ValidatorCalloutExtender>

2 . Use JavaScript to alter this CSS class when needed. Set display = none:

Mã:

function alterDisplay(type) {
var styleSheet, cssRule;
if (document.styleSheets) {
styleSheet = document.styleSheets[index1];
if (styleSheet) {
if (styleSheet.cssRules)
cssRule = styleSheet.cssRules[index2]; // Firefox
else if (styleSheet.rules)
cssRule = styleSheet.rules[index2]; // IE
if (cssRule) {
cssRule.style.display = type;
}
}
}
}

Note: the index1 and index2 may be difference from pages, it's up to your declaration. You can use IE debugger to find our the correctly index.
Hope they fix this problem in next release.

1 comments:

We can find right css instant in styleSheets array via it ID:

styleSheet = document.styleSheets["CUSIPStyle"];

Post a Comment