本文介绍了在asp.net点击两次按钮(自动回文本框后)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个网页我有:

<asp:TextBox runat="server" ID="EmailTextBox" AutoPostBack="true" OnTextChanged="EmailTextBox_Changed" />
<asp:Button runat="server" ID="SearchButton" OnClick="AddButton_Click" Text="add" />

在EmailTextBox_Changed,它计数多少封电子邮件可在运行搜索之前找到。

In EmailTextBox_Changed, it counts up how many emails can be found, before running the search.

问题是,当你键入EmailTextBox东西,并点击按钮,你必须点击两次以获得实际的结果了。这是因为第一次点击是做的AutoPostBack的一部分从文本框,然后你必须再次点击,使实际点击回发的情况发生。

The problem is, when you type something in EmailTextBox, and click on the button, you have to click twice to get the actual results up. This is because the first click is doing the "AutoPostBack" part from the text box, and then you have to click again to make the actual click postback to happen.

不删除的AutoPostBack =真,我怎么能阻止它需要两次点击在这种情况下?

Without removing the "AutoPostBack=true", how can I stop it needing two clicks in these circumstances?

推荐答案

使其成为一个客户端支票解决这个......似乎没有成为一个方式prevent它,否则

Making it a client side check was the solution to this...there doesn't seem to be a way to prevent it otherwise

这篇关于在asp.net点击两次按钮(自动回文本框后)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 20:17