从CustomValidator控件中的ControlToValidate属性中的控件中提取值?

时间:2011-02-02 22:03:09

标签: asp.net validation

如何获取在ClientValidationFunction属性中标识的JavaScript函数中的值,该属性是在ControlToValidate控件的asp:CustomValidator属性中标识的控件中输入的?

function MyValidateFunction(sender, args) {
    //want to get value of MyControl    
}

<asp:CustomValidator 
    ID="cvAlarmedLocationAddress" 
    runat="server" 
    ControlToValidate="MyControl" 
    ClientValidationFunction="MyValidateFunction" 
    Text="" 
/>

1 个答案:

答案 0 :(得分:2)

检查javascript中args.Value属性的值。以下是MSDN库中的C#示例:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.clientvalidationfunction.aspx#Y570