是否可以动态定位ValidatorCalloutExtender?

时间:2009-08-13 18:16:16

标签: c# asp.net javascript ajax ajaxcontroltoolkit

我有两个通过VB.net编程的ajax验证器标注扩展器。我正在验证一个文本框但我希望弹出窗口出现在不同的文本框旁边。如何告诉ajax弹出窗口出现在哪里?

    Dim custval As New CustomValidator
    custval.ID = "ValidPage"
    custval.ErrorMessage = "<font color=red>Please Enter a 'To' Date"
    custval.SetFocusOnError = True
    custval.ForeColor = Drawing.Color.Red
    custval.EnableClientScript = True
    custval.ControlToValidate = cell.Controls(18).ID
    custval.ClientValidationFunction = "ClientValidate"
    custval.Display = ValidatorDisplay.None
    Dim custvalex As New AjaxControlToolkit.ValidatorCalloutExtender
    custvalex.ID = "VCEcustval"
    custvalex.TargetControlID = "ValidPage"
    custvalex.HighlightCssClass = "validatorCalloutHighlight"
    '---------------------------------------------------------------
    Dim custval2 As New CustomValidator
    custval2.ID = "ValidPage2"
    custval2.ErrorMessage = "<font color=red>Please Enter a 'From' Date"
    custval2.SetFocusOnError = True
    custval2.ForeColor = Drawing.Color.Red
    custval2.EnableClientScript = True
    custval2.ControlToValidate = cell.Controls(23).ID
    custval2.ClientValidationFunction = "ClientValidate2"
    custval2.Display = ValidatorDisplay.None

    Dim custvalex2 As New AjaxControlToolkit.ValidatorCalloutExtender
    custvalex2.ID = "VCEcustval2"
    custvalex2.TargetControlID = "ValidPage2"
    custvalex2.HighlightCssClass = "validatorCalloutHighlight"
    cell.Controls.Add(custval) '27
    cell.Controls.Add(custvalex2) '28
    cell.Controls.Add(custval2) '29
    cell.Controls.Add(custvalex) '30


function ClientValidate(sender, args) {
    // Get Both form fields
    var hid = $get('<%=HiddenField1.ClientID%>');
    var hid2 = $get('<%=HiddenField2.ClientID %>');
    var hidval = hid.value;
    var hid2val = hid2.value;
    var txtdate1 = $get(hidval);
    var txtdate2 = $get(hid2val);
    // do you client side check to make sure they have something
    if (txtdate1.value != '' && txtdate2.value == '') {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}
function ClientValidate2(sender, args) {
    // Get Both form fields
    var hid = $get('<%=HiddenField1.ClientID%>');
    var hid2 = $get('<%=HiddenField2.ClientID %>');
    var hidval = hid.value;
    var hid2val = hid2.value;
    var txtdate1 = $get(hidval);
    var txtdate2 = $get(hid2val);
    // do you client side check to make sure they have something
    if (txtdate2.value != '' && txtdate1.value == '') {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

我知道这两个javascript函数可以分开。但是我怎样才能移动弹出窗口?

1 个答案:

答案 0 :(得分:0)

您可能必须通过CSS或javascript控制它的位置。我不知道通过服务器控件的属性来实现它的方法。

Here is a forum thread显示如何使用callout的set_x和set_y javascript方法重新定位验证器弹出窗口。