Button_Click event always firing on Postback

I created a web page with a text box and a image button (used to open a calendar)
In The text box you have the option of doing a search by writing a name or ID in it or using the image button to open a calendar and when you click a date it is populated in the textbox for you to do a search by date.
When I write in a name and hit enter to do a search it always runs the button_click event so I get the calendar on top of my results.
Can somebody give me an idea what I might be doing wrong

Thanks in advance
Niall292Asked:
Who is Participating?
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.

strickddCommented:
UseSubmitBehaviour="false" on the button
0
Niall292Author Commented:
Thank you for your help but I tried it on the imagebutton and it made no difference. The calendar still opened over the results
0
CodeCruiserCommented:
What do you want to happen when you press enter? Do you have any other button on page?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Niall292Author Commented:
When I press enter it should only post back the text put in the textbox to do the search. I only want the calendar to come up if I press the image button
0
Niall292Author Commented:
Something I think I should mention incase it makes any difference although I am not doing anything with Ajax I have a ScriptManager on my Masterpage for using log4net
0
CodeCruiserCommented:
You need to have a button on the page which does the posting back to server. Or you would need to handle the keypress of the textbox in Javascript and post the page back if Enter is encountered.
0
Niall292Author Commented:
I have always built my web pages so users only need to press enter to do a search but this is the first time I have had this problem. The keypress idea might work I must look up for examples on it and hopefully it will not cause the button_click event.
If you know of any good links with examples please let me know.
Thanks for your help
0
Niall292Author Commented:
Doing some testing I used the Keypress event and said if Enter then alert('Hello') and it brought up the alert box but the calendar was behind it.......AAAAAAHHHHH
0
Bill NolanOwner, Lead Technology ProgrammerCommented:
Check out Page.Form.SetDefaultButton & Panel.SetDefaultButton
0
Niall292Author Commented:
I tried the SetDefaultButton but to no avail.
I also have to apologise because I knew it had to be something simple as I never had this problem before.
I went into the properties of the textbox and set the Auto Postback = true and it worked
NO MORE CALENDAR
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
Niall292Author Commented:
I knew it had to be something simple and this was just a setting I missed
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.