Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 July 29th, 2004, 10:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default Enter Key

Hello,

What I want to do is something like this in an ASP.NET web form:

http://p2p.wrox.com/topic.asp?TOPIC_ID=16472

However, mine is a little different. What I want to do is when the enter key is pressed in a textbox, I want a link to be clicked through javascript.

Any ideas? Is that clear?

Brian
__________________
Brian
 
Old July 29th, 2004, 11:38 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Just make the javascript that is called:

document.location.href = "anotherpage.aspx";
 
Old July 29th, 2004, 11:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

It needs to generate server-side script... I should have clarified when I said earlier, that it needs to click a LinkButton.
 
Old July 29th, 2004, 03:10 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I *think* you might be able to do something like this on the client side:

myLinkButton.click();

I know you can do this with a button, but I'm not positive about doing so with an <a> link.
 
Old August 2nd, 2004, 03:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

It seems a little weird. When I just do:

if ( event.keyCode == 13 ) {
    document.getElementById('lnkButton').click();
}

It doesn't work. However, when I do:

if ( event.keyCode == 13 ) {
    document.getElementById('lnkButton').click();
    if (document.getElementById('lnkButton') == null ) {
        alert("NULL");
    }
}

It works. It seems to be because of the alert. Something with the alert is causing it to work. I really don't want to do the alert, just in case for some reason it is null, and that message shows. Is there another way. If not, I can live with it.

I'm declaring an onKeyPress by:

txtDefSearchText.Attributes.Add("onKeyPress", "Search();")

In the Page_Load event. In addition, the above code is within the Search.

Brian
 
Old August 3rd, 2004, 01:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Correction, the second one didn't work like it was yesterday... Although yesterday during testing when I popped up an alert, no matter if the linkbutton reference existed or not, the alert popped up and it committed the search. It seems like the alert gets it "over the hump" so to speak. Any ideas why?

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Enter Key Event (Enter Key Only) Coby Excel VBA 0 February 6th, 2008 09:55 PM
use enter key to exit mastrgamr C++ Programming 1 January 18th, 2007 10:50 AM
how to disable enter key for a particular button g_vamsi_krish ASP.NET 1.0 and 1.1 Professional 1 January 19th, 2006 11:22 AM
How would you determine the "ENTER' key? mcinar HTML Code Clinic 15 March 24th, 2005 10:55 PM
Enter Key rwalker VB How-To 5 April 7th, 2004 11:04 AM





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