Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 17th, 2005, 12:37 PM
Authorized User
 
Join Date: Mar 2005
Location: Mumbai, Maharastra, India.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default how can use keypress event in a web application?

as we write our question on google and press enter
we dont need to click sear button it auto matically opens on pressing enter key ,its windows forms facility how can we apply in seb applications?
Reply With Quote
  #2 (permalink)  
Old March 24th, 2005, 06:13 AM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

U can use script to achieve that functionality

function click (e, buttonid){
      var t = document.getElementById(buttonid);
      if (typeof t == 'object')
{
            if(navigator.appName.indexOf("Netscape")>(-1))
{
        if (e.keyCode == 13)
{
         t.click();
         return false;
      }
}
if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
{
                  if (event.keyCode == 13)
{
   t.click();
   return false;
}

     }
}
}
//code behind
TextBox1.Attributes.Add("onkeypress", "return click(event,'" + Button1.ClientID + "')");

The code behind generates the following code:

<input name="TextBox1" type="text" id="TextBox1" onkeypress="return click(event,'Button1')" />

This causes web control Button1 to be clicked when the enter key is hit inside TextBox1.

This can easily be extended to support other browsers either by browser detection or object detection.




Reply With Quote
  #3 (permalink)  
Old April 24th, 2005, 09:14 PM
Registered User
 
Join Date: Apr 2005
Location: xian, , China.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 i am is chinese .i now only a little english. i want to tell you.but i can not write it in english . ----china city xian

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASCII code on keypress event ashokkumar .NET Framework 1.x 9 March 29th, 2007 07:50 AM
keypress event kau_shuk VB.NET 2002/2003 Basics 1 July 31st, 2006 11:21 AM
KeyPress event jbenson001 VB.NET 2002/2003 Basics 1 March 24th, 2005 04:52 PM
Keypress Event bharatsaboo VB.NET 2002/2003 Basics 0 February 25th, 2005 03:34 AM
KeyPress Event in VB different from VBA PaulG Beginning VB 6 3 February 3rd, 2004 01:31 PM



All times are GMT -4. The time now is 12:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.