• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 53
  • Last Modified:

ASP.NET

HI guys,
I have asp.net application and have button which is implemented on the server side.

<asp:TextBox ID="txtObject" onfocus="this.select();" runat="server" AutoPostBack="True" CssClass="form-control"></asp:TextBox>

Open in new window


I would like to fire this textbox just when user click ENTER key = 13, for now I used the method onchange "txtObject_TextChanged" as it is the only option i have in asp.net.

The issue I have is if I change anything in the textbox it postback and I would like to postback just when I press enter in the textbox.

I also tried to setup the  AutoPostBack to false and It didn't worked for me as if you set it to false the enter key will not work as well.

please any suggestions.

Thank you.
0
Moti Mashiah
Asked:
Moti Mashiah
  • 2
1 Solution
 
Ryan ChongCommented:
The issue I have is if I change anything in the textbox it postback and I would like to postback just when I press enter in the textbox.
you no need to do any changes to your existing ASP control:

the below code is good enough for you.

<asp:TextBox ID="txtObject" onfocus="this.select();" runat="server" AutoPostBack="True" CssClass="form-control"></asp:TextBox>

hence you no need to add the TextChanged to detect the enter key, unless you need to use it for other process?
0
 
Ryan ChongCommented:
any further clarification is needed here?
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
thanks, its solve my issue.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now