简体   繁体   English

在asp.net vb.net中为文本框保留事件

[英]leave event for textbox in asp.net vb.net

I'm looking for a solution for the textbox leave event in asp.net vb.net. 我在asp.net vb.net中寻找文本框离开事件的解决方案。 I have searched but Didn't get the right solution, what I'm actually doing is. 我已经搜索过,但是没有找到正确的解决方案,我实际上正在做的是。

I have textbox in which a user write the Product Id number however the focus moved from the textbox then all the related data should be displayed on the concern textboxes . 我有一个textbox ,用户在其中输入Product Id号,但是焦点已从textbox移开,然后所有相关数据都应显示在关注textboxes

Their is no textbox_lostfocus event or textbox_keydown event available in ASP.Net . 它们不是ASP.Net可用的textbox_lostfocus事件或textbox_keydown事件。 You can do the same by writing the code in TextChanged event of the Text Box. 您可以通过在“ 文本框”的 TextChanged事件中编写代码来执行相同的操作 Your code will be like the following : 您的代码将如下所示:

  Private Sub txtamount_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtamount.TextChanged
   //Your code comes here
   MsgBox(txtamount.Text)// sample display
  End Sub

This code will give result only when you add AutoPostBack ="true" with your Textbox design. 仅当在Textbox设计中添加AutoPostBack ="true"时,此代码才会给出结果。

ie., the ASP code for the textbox will be : 即,文本框的ASP代码为:

<asp:TextBox ID="txtamount" runat="server" AutoPostBack ="true"  />

Hope that this is actually your are asking for. 希望这实际上是您的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM