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.
LVL 1
Moti Mashiah.NET DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
any further clarification is needed here?
0
Moti Mashiah.NET DeveloperAuthor Commented:
thanks, its solve my issue.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.