ConfirmButtonExtender问题之前的验证 [英] validation before ConfirmButtonExtender problem

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

问题描述

大家好...
在验证之前,我在屏幕上单击botton1 ConfirmButtonExtender消息处理程序时,在Textbox1上具有requiredfieldvalidator.

Hello EveryOne...
I have requiredfieldvalidator On Textbox1 whan i click on botton1 ConfirmButtonExtender message apper on screen before the validation.

推荐答案

我认为您没有阅读ConfirmButton的文档.从ASP.Net检查示例,不要忘记阅读ConfirmOnFormSubmit属性.

ConfirmButton演示 [
I think you did not read documentation of ConfirmButton. Check samples from ASP.Net and don''t forget to read ConfirmOnFormSubmit Property.

ConfirmButton Demonstration[^]

still facing problem after read this check below code


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
     <asp:ConfirmButtonExtender ID="cbe" runat="server"

    TargetControlID="Button1"

    ConfirmText="Are you sure you want to click this?"

    ConfirmOnFormSubmit="false"

     />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"

        ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator">
    </asp:RequiredFieldValidator>


当您使用ajax ConfirmButtonExtender时,将在确认消息之后对页面进行验证. 为了避免这种情况,您必须使用Java脚本向用户确认...
有点像这样...

when you use ajax ConfirmButtonExtender your validations of page will be done after the Confirmation Message....
to avoid this you have to confirm from user using Javascript...
somewhat like this...

function checkBeforeConfirm()//put this javascript function
{
    if(Page_ClientValidate()==true)//method to check validations
    {
         if(confirm(''Are You Sure with the Details?'')==true)//confirm after validations check
         {
              return true;
         }
         else
         {
              return false;
         }
    }
    else
    {
         return false;
    }
}



如果您已将验证分为几组,则



if you have divided your validations into groups then

function checkBeforeConfirm()//put this javascript function
{
    if(Page_ClientValidate(''validationGroup'')==true)//method to check validations
    {
         if(confirm(''Are You Sure with the Details?'')==true)//confirm after validations check
         {
              return true;
         }
         else
         {
              return false;
         }
    }
    else
    {
         return false;
    }
}



在Button的"OnClientClick"属性上调用此功能..



on your "OnClientClick" Property of your Button call this funtion..

<asp:button id=".." ...="" onclientclick="return checkBeforeConfirm();" xmlns:asp="#unknown"></asp:button>



这可以从此获得帮助



this you will get help from this


这篇关于ConfirmButtonExtender问题之前的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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