I have a custom gridview with an export to excel feature, a column for edit/delete buttons in each row that is populated, and a footer that allows for new items to be added.
Somthing a little like this:
Showing 1-8 of 8
| Results per page: 25 50 All |Export Button|
|
BRONCO
| Edit / Delete
|
FLTPLAN
| Edit / Delete
|
LASSO
| Edit / Delete
|
PINTO
| Edit / Delete
|
RANCH
| Edit / Delete
|
RODEO
| Edit / Delete
|
TEXAN
| Edit / Delete
|
TEST
| Edit / Delete
|
|Empty Text Box|
| Add
|
(excuse my lazy html)
After navigating to that page a user would be able press the return key and, because it is the only button on the page, the export to excel button would be activated. I used the following Javascript to stop this:
<script type="text/javascript">
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = stopRKey;
</script>
While this is great for when the user navigates to the page, after editing an item in the gridview, the user can press enter and get the export button again. I know the script is working so I am absolutely perplexed why it's still allowing the return key after I edit/add something in the gridview.
Other (possibly) noteworthy items:
The gridview is in an update panel. Putting the javascript in the udp doesn't change anything.
The gridview is using a linq data source.
I've tried using the jscript in both the .aspx page and the master page (and both at the same time for some illogical reason).