Catpuring Button Press In A WebForm
-
I have a WebForm and I need a way to set what button event is fired upon the press of a key(specifically the Enter key), I tired TabIndex, is it something to do with the AccessKey? Thanks in Advance .............Zack............. Developer Extraordinaire "It's all about function over form. I mean, look at NASA. Their code isn't formatted correctly and their stuff looks crappy, but, they'll get you to the moon." GCS\P\SS d- s-:- a-- C++$ U--- P--- L- E- W++ N o K-? w+++ O++ !M-- V PS+ PE Y+ PGP t+ 5+ X+ R++ tv++ b++ DI++ D+++ G+>G++++ e* h- r++ y+
-
I have a WebForm and I need a way to set what button event is fired upon the press of a key(specifically the Enter key), I tired TabIndex, is it something to do with the AccessKey? Thanks in Advance .............Zack............. Developer Extraordinaire "It's all about function over form. I mean, look at NASA. Their code isn't formatted correctly and their stuff looks crappy, but, they'll get you to the moon." GCS\P\SS d- s-:- a-- C++$ U--- P--- L- E- W++ N o K-? w+++ O++ !M-- V PS+ PE Y+ PGP t+ 5+ X+ R++ tv++ b++ DI++ D+++ G+>G++++ e* h- r++ y+
To associate button click events with a postback caused by pressing enter, use my DefaultButtons control.
-
I have a WebForm and I need a way to set what button event is fired upon the press of a key(specifically the Enter key), I tired TabIndex, is it something to do with the AccessKey? Thanks in Advance .............Zack............. Developer Extraordinaire "It's all about function over form. I mean, look at NASA. Their code isn't formatted correctly and their stuff looks crappy, but, they'll get you to the moon." GCS\P\SS d- s-:- a-- C++$ U--- P--- L- E- W++ N o K-? w+++ O++ !M-- V PS+ PE Y+ PGP t+ 5+ X+ R++ tv++ b++ DI++ D+++ G+>G++++ e* h- r++ y+
Hi, I actually had a similar problem and circumvented it with a JavaScript trick. First you need to cut the wireup that VS.NET puts for ASP Buttons. Use HtmlButtons only. ON ButtonClick and Enter Button, call a generic JavaScript function, set a hidden field to a specified value 'add', 'update', 'delete', 'change' etc. and then submit the form. The control will goto PageLoad. Now in PageLoad, If (Postback) check for the value of hidden field and execute that method now. Did this solve the problem. Alternatively, you can create a Button Control and use that instead of the default ASP Buttons and HtmlButtons too. That is more elegant, though, the first time, time investment, it takes to create is more. Deepak Kumar Vasudevan http://deepak.portland.co.uk/