禁用回发或停止检查asp.net页面中按钮的验证 [英] disabling the postback or stop checking validation for a button in asp.net page

查看:55
本文介绍了禁用回发或停止检查asp.net页面中按钮的验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  protected   void  Button6_Click(对象发​​件人,EventArgs e)
{
ddl_title.Items.Add(TextBox1.Text.ToString());
lblAddedSalutation.Text = 现在可以选择新标题;
}







我将文本添加到ASP.net页面的下拉列表中。



工作正常,但是这个按钮下方的文本框很少,我在这些文本框中使用了必需的字段验证器。



当文本框为空时,页面正在重新加载,并要求我输入文本框,但我不在此阶段进行requiredfield验证器检查。

解决方案

您好,您无法禁用回发,但您可以使用客户端回发,它使用Asp.net ajax扩展(在工具箱中)快速且易于使用。



这里是如何使用它的链接:

http://www.youtube.com/watch?v=3HdJu1U6ciQ


只需为requiredfieldvalidator添加display =dynamic

就像这样

 < ;   asp:RequiredFieldValidator     ID   =  RequiredFieldValidator1     runat   = < span class =code-keyword> server  

< span class =code-attribute> ControlToValidate = TextBox1 显示 = 动态 SetFocusOnError = true ErrorMessage = * ForeColor = 红色 > < / asp:RequiredFieldValidator >


protected void Button6_Click(object sender, EventArgs e)
   {
       ddl_title.Items.Add(TextBox1.Text.ToString());
       lblAddedSalutation.Text = "Your new title is now ready to be selected";
   }




I am adding the text to a dropdown in ASP.net page.

It is working fine but I have few text boxes below this button and I have used required field validator for those text boxes.

When the textboxes are empty the page is re-loading and ask me to enter the text boxes but I don't to do the requiredfield validator checking at this stage.

解决方案

Hi, you can't disable postback, but you can use client side postback, its fast and easy to use with Asp.net ajax extension (in the tool box).

here is a link how to use it:
http://www.youtube.com/watch?v=3HdJu1U6ciQ


just add display="dynamic" for the requiredfieldvalidator
like this

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

            ControlToValidate="TextBox1"  Display="Dynamic" SetFocusOnError="true" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>


这篇关于禁用回发或停止检查asp.net页面中按钮的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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