Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button vs Text Box AutoPostBack Problem 1

Status
Not open for further replies.

bburnell

Programmer
Sep 15, 2000
560
US
Hi all,

I am running VS.net 2003 with asp and vb on Windows XP. I have a text box that does an auto post back if the text is changed. I also have a submit button.

Currently, the user can do this 3 ways:

1) If the user inputs a part # and clicks the submit button (without tabbing off of it), it only does the autopostback portion and retrieves the part description.

2) If the user tabs (gets the description) and then clicks submit, everything works fine.

3) If the user enters the part # and hits the enter key, it does the autopostback and submit function.

#1 is the porblem. If I could get #1 to act like #3 I'd have it the way I want it. In other words, is there a way to force the submit button to work in addition to the postback or give it a priority over the textchanged property?

My variables are called:
btnSubmit (button)
txtUnitPartNumber (text box)

My routines are called:
txtUnitPartNumber_TextChanged
btnSubmit_Click

I hope I explained this ok. Thanks in advance for the help!
Brett
 
Put your textchanged code in a sub
sub textchanged()

Call that from txtUnitPartNumber_TextChanged AND
btnSubmit_Click


 
Thanks jbenson. I tried that already and it didn't work. The problem is that if the text has been changed, it is never getting to the btnSubmit_Click routine. It always goes to the textchanged code without going to the submit_click code. If the text hasn't chaged, then it works fine.

I did a little bit of research on this since I posted it and it seems that if the project is in "release" status, it works fine. If it's in "debug" status, it doesn't. Go figure.

Any more ideas?
Brett
 
very strange behavior.. didn't think the release mode would matter.
 
the only thing that i can think of is that the TAB action is taking some time to work in situation #1...

Known is handfull, Unknown is worldfull
 
what about disabling the submit button once the text box gains focus, and then enabling after the text change event is called. Though you may need a label to make visible and hide to let the user know why the button is not enabled. Just a thought that might be more trouble than its worth
 
Good idea. I'll run it over with the client and see what they think.
Thanks!
Brett

P.S. There has to be an easier way! :p
 
Quick question, how do I check if the textbox has focus? In Access it was textbox.gotfocus or something. Any help is greatly appreciated!

Thanks,
Brett
 
As a TextBox is a server-side control, and focus is a client-side attribute, you'll have to use a javascript method to finds this out. This can then be passed back to the server via a hidden input if you need to access it on the server.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top