Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 5th, 2010, 06:50 PM
Authorized User
 
Join Date: Jul 2010
Posts: 23
Thanks: 7
Thanked 2 Times in 1 Post
Default OnKeyDown event fires twice

Hello

I have a FormView wich is used to submit comments. I have added an extra attribute to the TextBox were the comment is written, so that when i have focus on the TextBox and press Enter i activate the Insert button. The problem is that it allways inserts twice, leaving 2 identical comments in the database.

Code:
Dim b As LinkButton = ComField.Controls.Item(0).FindControl("InsertButton")
Dim txtb As TextBox = ComField.Controls.Item(0).FindControl("Comment1TextBox")
txtb.Attributes.Add("OnKeyDown", "javascript:if (event.keyCode == 13) __doPostBack('" + b.UniqueID + "','')")
I am really new with JavaScript so i need some help to deactivate the key before i run the code, or something like that.
 
Old September 6th, 2010, 12:01 PM
Authorized User
 
Join Date: Jul 2010
Posts: 23
Thanks: 7
Thanked 2 Times in 1 Post
Default

Never mind. I worked around it by deleting comments that are identical to the previous one. Works as a spam filter too :P





Similar Threads
Thread Thread Starter Forum Replies Last Post
Save button fires twice luckystar BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 2 December 22nd, 2009 06:46 PM
GridView Delete Event fires twice Scott663 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 May 11th, 2007 05:36 AM
MouseOut event fires constantly MrSander BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 0 May 3rd, 2006 11:09 AM
Capturing the onkeydown event richard.york Javascript How-To 5 December 27th, 2005 04:27 PM
Session_Start fires twice!!? Dmitriy Pro VB 6 1 March 17th, 2005 12:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.