使用自定义控件验证器进行服务器端验证 [英] server side validation using custom control validator

查看:72
本文介绍了使用自定义控件验证器进行服务器端验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用自定义控件验证器来应用服务器端验证,但是我不想在script标签中编写函数.
我正在使用内联编码.

我想将函数存储在另一个文件中,并希望从中访问.

请帮帮我.

I want to apply server side validation using custom control validator, but I dont want to write a function in script tag.
I''m using inline coding.

I want to store functions in another file and want to access from that.

Please help me out.

推荐答案

我想使用自定义控件验证器来应用服务器端验证.
做这样的事情
I want to apply server side validation using custom control validator.
Do something like this
<asp:CustomValidator ID="valCaptcha" runat="server" ControlToValidate="txt1"

 ErrorMessage="Your error message here" Text="*" OnServerValidate="valCaptcha_ServerValidate" ValidateEmptyText="True" />





protected void valCaptcha_ServerValidate(object source, ServerValidateEventArgs args) {
           //your code to validate.
            
        }



如果我理解您错了,请纠正我.



Correct me if I understand you wrong.


在哪里编写这段代码?
bcoz m在运行时创建页面.
例如:假设有一个页面接受控件ID和将在其上执行的验证名称.仅这是输入.没有其他任何物理页面.通过仅使用此输入,我想创建一个新页面,上面的控件动态地应用了n个验证.
我也同时执行服务器端和客户端验证.

我现在想您可以理解我的prblm ...所以请帮助我.
where to write this code?
bcoz m creating pages at runtime.
e.g.: supppose there is a page which accepts control id and name of validations which will be perform on that. Only this is the input. No any other physical page is present. By using only this input i wanna create a new page with above controls n validations applied on them, dynamically.
Also i hv to perform server side as well as client side validations at the same time.

I thnk now you can understood my prblm...so plz help me.


这篇关于使用自定义控件验证器进行服务器端验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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