English 中文(简体)
积极增加有效人员
原标题:dynamically adding validators
  • 时间:2011-04-17 13:39:31
  •  标签:
  • c#
  • asp.net

在我的案件中,我要根据某种逻辑,积极增加我的控制效力。 对于每一项控制,我首先在我的行文中检查一些东西,如果说需要实地检查的话,我想补充一下。 实地控制。 我通过每一次控制进行追捕,如果要求我增加“真实”所需的属性。

我补充了这一法典,但我肯定了我的工作,这意味着没有发生任何事情,也没有进行验证。

if(gc.Attributes["controlid"] != null)
    {
        RequiredFieldValidator validator = new RequiredFieldValidator();
        validator.ControlToValidate = gc.Attributes["controlid"];
        validator.ErrorMessage = gc.Attributes["errormessage"];
        this.Controls.Add(validator);
    }

Thanks for any suggestions.

问题回答

您还必须在网页有效器收集上添加这一内容,以便服务器的侧面验证。 仅与你一样,在网页控制收集上添加这一信息,是使Java文本得到验证才能被浏览。

Page.Validators.Add(validator);

Are you adding your Validator control to the same container as the control it validates? Validator controls require the target control to be in the same INamingContainer.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签