原因验证=真不触发服务器按钮单击事件 [英] Cause Validation = True Not Firing Server Button Click Event

查看:49
本文介绍了原因验证=真不触发服务器按钮单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...
我在设计页面中使用按钮进行设置,并设置了validation = true,以使用验证组对所有控件进行验证.但是现在按钮不会在服务器端被触发.我需要同时进行验证和服务器端事件....PLZ指南很快

这是我的设计代码:

Hi...
Im using a button for in design page and set causes validation=true for validation all controls using validation group. But now button not getting fired in server side. I need to do both validation and server side event....plz guide soon

This is my design code:

<asp:Button ID="btnNext" runat="server" Text="Next Step" SkinID="Button"
                    ValidationGroup="valControls" onclick="btnNext_Click"
                    CausesValidation="False" />




这是我的CS代码:




This is my cs code:

protected void btnNext_Click(object sender, EventArgs e)
        {
            ccJoin.ValidateCaptcha(txtCaptcha.Text);
            if (ccJoin.UserValidated)
            {
                lblMsg.Text = "Incorrect code";

            }
            else
            {
                lblMsg.Text = "Code matched";

                }
            return;


}

推荐答案

Priyaaammu,当客户端验证变为false时,您的服务器端验证将自动触发(因为您已经使用.net验证控件).
谢谢
Ashish
Priyaaammu, Your server side validation will automatically get fired when client side validation will become false(As you have use .net validation controls).
Thanks
Ashish




首先让我告诉您一件事,如果您正在使用验证组,那么该组中的所有控件都将被验证.如果验证完成且结果为true,则仅将触发服务器端代码.检查该组中的控件.如果任何控件出现错误,则将不会触发服务器端代码.

只需从您的按钮中删除验证组即可.试试这个:
Hi,

First of all let me tell you one thing that if you are using validation group then all the controls of that group will be validated. If validation is done and result is true then only the server side code will be fire. Check for your controls in that group. If any of the controls is giving error means the server side code will not be fired.

Just remove the validation group from your button. Try this:
<asp:Button ID="btnNext" runat="server" Text="Next Step" SkinID="Button"
onclick="btnNext_Click" CausesValidation="False" />


--Amit


--Amit


这篇关于原因验证=真不触发服务器按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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