在验证器上设置ControlToValidate [英] Setting the ControlToValidate on a Validator

查看:110
本文介绍了在验证器上设置ControlToValidate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在根据数据库信息重新编写动态表格.

I am currently re-writing a dynamic form based on database information.

此表单包含许多特定于项目"的属性,每个属性都有一个控件和标签,例如Category的标签上显示"Category"和一个包含所有选项的DropDownList.

This form contains numerous 'Item Specific' properties, each of which has a single control and label, for example Category has a label that says "Category" and a DropDownList that contains all the options.

我现在发现的问题是,通过基于数据库中的一些信息(属性的名称,选项和属性(例如文本或下拉列表))以编程方式创建的每一项都被添加到页面中,并且每一项至少具有一个验证器,以确保输入的数据正确无误.

The problem I now find is that each of these is added to the page by being created programatically based on some information from the database (Property name, options and tpye of property, such as text or dropdown), and each of these has at least one validator to ensure data entered in it is correct.

这提供了一个问题:当我将每个组件作为对象而不是aspx上的静态对象进行验证时,如何在验证器上设置ControlToValidate(也以编程方式创建)?

This provides a problem: How can I set the ControlToValidate on the validators (Also created programatically) when I have each component to be validated as an object, not a static thing on the aspx?

推荐答案

确保您的控件具有ID,并相应地设置Validator.ControlToValidate属性.

Make sure your controls have ID's and set the Validator.ControlToValidate property accordingly.

这篇关于在验证器上设置ControlToValidate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆